robshakir / pyangbind

A plugin for pyang that creates Python bindings for a YANG model.
Other
204 stars 121 forks source link

Deprecation warning due to invalid escape sequences #270

Closed tirkarthi closed 9 months ago

tirkarthi commented 4 years ago

Deprecation warnings are raised due to invalid escape sequences. This can be fixed by using raw strings or escaping the literals. pyupgrade also helps in automatic conversion : https://github.com/asottile/pyupgrade/

find . -iname '*.py' | grep -v example | xargs -P4 -I{} python3.8 -Wall -m py_compile {}
./pyangbind/lib/xpathhelper.py:109: DeprecationWarning: invalid escape sequence \[
  _attr_re = regex.compile("^(?P<tagname>[^\[]+)(?P<args>(\[[^\]]+\])+)$")
./pyangbind/lib/xpathhelper.py:111: DeprecationWarning: invalid escape sequence \-
  "^((and|or) )?[@]?(?P<cmd>[a-zA-Z0-9\-\_:]+)([ ]+)?"
./pyangbind/lib/xpathhelper.py:115: DeprecationWarning: invalid escape sequence \.
  _relative_path_re = regex.compile("^(\.|\.\.)")
./pyangbind/lib/xpathhelper.py:178: DeprecationWarning: invalid escape sequence \(
  remaining_path = regex.sub("current\(\)(?P<remaining>.*)", "\g<remaining>", v).split("/")
./pyangbind/lib/xpathhelper.py:178: DeprecationWarning: invalid escape sequence \g
  remaining_path = regex.sub("current\(\)(?P<remaining>.*)", "\g<remaining>", v).split("/")
./pyangbind/lib/xpathhelper.py:206: DeprecationWarning: invalid escape sequence \g
  tagname, args = self._attr_re.sub("\g<tagname>||\g<args>", tag).split("||")
./pyangbind/lib/xpathhelper.py:214: DeprecationWarning: invalid escape sequence \g
  c, a, r = self._arg_re.sub("\g<cmd>||\g<arg>||\g<remainder>", tmp_arg).split("||")
./pyangbind/lib/xpathhelper.py:231: DeprecationWarning: invalid escape sequence \.
  if regex.match("^\.\.", object_path[0]):
./pyangbind/lib/xpathhelper.py:284: DeprecationWarning: invalid escape sequence \.
  if regex.match("^(\.|\.\.|\/)", object_path[0]):
./pyangbind/lib/yangtypes.py:184: DeprecationWarning: invalid escape sequence \g
  current_restricted_class_type = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", six.text_type(base_type))
./pyangbind/lib/yangtypes.py:226: DeprecationWarning: invalid escape sequence \-
  range_regex = regex.compile("(?P<low>\-?[0-9\.]+|min)([ ]+)?\.\.([ ]+)?" + "(?P<high>(\-?[0-9\.]+|max))")
./pyangbind/lib/yangtypes.py:226: DeprecationWarning: invalid escape sequence \-
  range_regex = regex.compile("(?P<low>\-?[0-9\.]+|min)([ ]+)?\.\.([ ]+)?" + "(?P<high>(\-?[0-9\.]+|max))")
./pyangbind/lib/yangtypes.py:227: DeprecationWarning: invalid escape sequence \-
  range_single_value_regex = regex.compile("(?P<value>\-?[0-9\.]+)")
./pyangbind/lib/yangtypes.py:240: DeprecationWarning: invalid escape sequence \$
  tmp_pattern = tmp_pattern.replace("$", "\$")
./pyangbind/lib/yangtypes.py:263: DeprecationWarning: invalid escape sequence \g
  eqval = range_single_value_regex.sub("\g<value>", range_spec)
./pyangbind/lib/yangtypes.py:254: DeprecationWarning: invalid escape sequence \g
  low, high = range_regex.sub("\g<low>,\g<high>", range_spec).split(",")
./pyangbind/lib/yangtypes.py:1029: DeprecationWarning: invalid escape sequence \g
  _pybind_base_class = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", str(base_type))
./pyangbind/lib/yangtypes.py:1295: DeprecationWarning: invalid escape sequence \g
  self._type = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", str(get_method()._base_type))
./tests/serialise/openconfig-serialise/run.py:56: DeprecationWarning: invalid escape sequence \_
  "interfaces\_ph:(?P<pathhelper>[a-zA-Z]+)\-flt:(?P<filter>[a-zA-Z]+)\-m:(?P<mode>[a-zA-Z]+)\.json",
./tests/serialise/openconfig-serialise/run.py:57: DeprecationWarning: invalid escape sequence \g
  "\g<pathhelper>||\g<filter>||\g<mode>",
JoseIgnacioTamayo commented 1 year ago

Hi,

Could you please try again with recent versions of pyangbind?

Thanks.

JoseIgnacioTamayo commented 9 months ago

Closing issue without recent updates.