Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Py12 to tests and package #343

Merged
merged 3 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down
18 changes: 9 additions & 9 deletions pyangbind/lib/xpathhelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ def __init__(self):


class YANGPathHelper(PybindXpathHelper):
_attr_re = regex.compile("^(?P<tagname>[^\[]+)(?P<args>(\[[^\]]+\])+)$")
_attr_re = regex.compile(r"^(?P<tagname>[^\[]+)(?P<args>(\[[^\]]+\])+)$")
_arg_re = regex.compile(
"^((and|or) )?[@]?(?P<cmd>[a-zA-Z0-9\-\_:]+)([ ]+)?"
+ "=([ ]+)?['\"]?(?P<arg>[^ ^'^\"]+)(['\"])?([ ]+)?"
r"^((and|or) )?[@]?(?P<cmd>[a-zA-Z0-9\-\_:]+)([ ]+)?"
+ r"=([ ]+)?['\"]?(?P<arg>[^ ^'^\"]+)(['\"])?([ ]+)?"
+ "(?P<remainder>.*)"
)
_relative_path_re = regex.compile("^(\.|\.\.)")
_relative_path_re = regex.compile(r"^(\.|\.\.)")

def __init__(self):
# Initialise an empty library and a new FakeRoot class to act as the
Expand Down Expand Up @@ -175,7 +175,7 @@ def _encode_path(self, path, mode="search", find_parent=False, normalise_namespa
for k, v in six.iteritems(attributes):
# handling for rfc6020 current() specification
if "current()" in v:
remaining_path = regex.sub("current\(\)(?P<remaining>.*)", "\g<remaining>", v).split("/")
remaining_path = regex.sub("current\(\)(?P<remaining>.*)", r"\g<remaining>", v).split("/")
# since the calling leaf may not exist, we need to do a
# lookup on a path that will do, which is the parent
if remaining_path[1] == "..":
Expand Down Expand Up @@ -203,15 +203,15 @@ def _encode_path(self, path, mode="search", find_parent=False, normalise_namespa
def _tagname_attributes(self, tag, normalise_namespace=True):
tagname, attributes = tag, None
if self._attr_re.match(tag):
tagname, args = self._attr_re.sub("\g<tagname>||\g<args>", tag).split("||")
tagname, args = self._attr_re.sub(r"\g<tagname>||\g<args>", tag).split("||")
arg_parts = [i.strip("[") for i in args.split("]")]

attributes = {}
for arg in arg_parts:
tmp_arg = arg
while len(tmp_arg):
if self._arg_re.match(tmp_arg):
c, a, r = self._arg_re.sub("\g<cmd>||\g<arg>||\g<remainder>", tmp_arg).split("||")
c, a, r = self._arg_re.sub(r"\g<cmd>||\g<arg>||\g<remainder>", tmp_arg).split("||")
if ":" in c and normalise_namespace:
c = c.split(":")[1]
attributes[c] = a
Expand All @@ -228,7 +228,7 @@ def register(self, object_path, object_ptr, caller=False):
if isinstance(object_path, str):
raise XPathError("not meant to receive strings as input to register()")

if regex.match("^\.\.", object_path[0]):
if regex.match(r"^\.\.", object_path[0]):
raise XPathError("unhandled relative path in register()")

# This is a hack to register anything that is a top-level object,
Expand Down Expand Up @@ -281,7 +281,7 @@ def register(self, object_path, object_ptr, caller=False):
def unregister(self, object_path, caller=False):
if isinstance(object_path, str):
raise XPathError("should not receive paths as a str in unregister()")
if regex.match("^(\.|\.\.|\/)", object_path[0]):
if regex.match(r"^(\.|\.\.|\/)", object_path[0]):
raise XPathError("unhandled relative path in unregister()")

existing_objs = self._get_etree(object_path)
Expand Down
18 changes: 10 additions & 8 deletions pyangbind/lib/yangtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def RestrictedClassType(*args, **kwargs):
# this gives deserialisers some hints as to how to encode/decode this value
# it must be a list since a restricted class can encapsulate a restricted
# class
current_restricted_class_type = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", six.text_type(base_type))
current_restricted_class_type = regex.sub("<(type|class) '(?P<class>.*)'>", r"\g<class>", six.text_type(base_type))
if hasattr(base_type, "_restricted_class_base"):
restricted_class_hint = getattr(base_type, "_restricted_class_base")
restricted_class_hint.append(current_restricted_class_type)
Expand Down Expand Up @@ -228,8 +228,8 @@ def __new__(self, *args, **kwargs):
_restriction_test method so that it can be called by other functions.
"""

range_regex = regex.compile("(?P<low>\-?[0-9\.]+|min)([ ]+)?\.\.([ ]+)?" + "(?P<high>(\-?[0-9\.]+|max))")
range_single_value_regex = regex.compile("(?P<value>\-?[0-9\.]+)")
range_regex = regex.compile(r"(?P<low>\-?[0-9\.]+|min)([ ]+)?\.\.([ ]+)?" + r"(?P<high>(\-?[0-9\.]+|max))")
range_single_value_regex = regex.compile(r"(?P<value>\-?[0-9\.]+)")

def convert_regexp(pattern):
# Some patterns include a $ character in them in some IANA modules, this
Expand All @@ -241,7 +241,7 @@ def convert_regexp(pattern):
trimmed = True
else:
tmp_pattern = pattern
tmp_pattern = tmp_pattern.replace("$", "\$")
tmp_pattern = tmp_pattern.replace("$", r"\$")
pattern = tmp_pattern
if trimmed:
pattern += "$"
Expand All @@ -255,7 +255,7 @@ def convert_regexp(pattern):

def build_length_range_tuples(range, length=False, multiplier=1):
if range_regex.match(range_spec):
low, high = range_regex.sub("\g<low>,\g<high>", range_spec).split(",")
low, high = range_regex.sub(r"\g<low>,\g<high>", range_spec).split(",")
if not length:
high = base_type(high) if not high == "max" else None
low = base_type(low) if not low == "min" else None
Expand All @@ -264,7 +264,7 @@ def build_length_range_tuples(range, length=False, multiplier=1):
low = int(low) * multiplier if not low == "min" else None
return (low, high)
elif range_single_value_regex.match(range_spec):
eqval = range_single_value_regex.sub("\g<value>", range_spec)
eqval = range_single_value_regex.sub(r"\g<value>", range_spec)
if not length:
eqval = base_type(eqval) if eqval not in ["max", "min"] else None
else:
Expand Down Expand Up @@ -1021,7 +1021,7 @@ class YANGBaseClass(base_type):
if yang_type in ["container", "list"] or is_container == "container":
__slots__ = tuple(clsslots)

_pybind_base_class = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", str(base_type))
_pybind_base_class = regex.sub("<(type|class) '(?P<class>.*)'>", r"\g<class>", str(base_type))

def __new__(self, *args, **kwargs):
try:
Expand Down Expand Up @@ -1287,7 +1287,9 @@ def __init__(self, *args, **kwargs):

if value is not None:
set_method(value)
self._type = regex.sub("<(type|class) '(?P<class>.*)'>", "\g<class>", str(get_method()._base_type))
self._type = regex.sub(
r"<(type|class) '(?P<class>.*)'>", r"\g<class>", str(get_method()._base_type)
)

self._utype = get_method()._base_type
self._ptr = True
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ classifiers =
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy

Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py{37,38,39,310,311},py,black
envlist = py{37,38,39,310,311,312},py,black
skip_missing_interpreters = True

[testenv]
Expand Down
Loading