Skip to content

Commit

Permalink
Use split() with maxsplit, bump pylint from 3.2.7 to 3.3.1 (#473)
Browse files Browse the repository at this point in the history
* Bump pylint from 3.2.7 to 3.3.1

Bumps [pylint](https://github.com/pylint-dev/pylint) from 3.2.7 to 3.3.1.
- [Release notes](https://github.com/pylint-dev/pylint/releases)
- [Commits](pylint-dev/pylint@v3.2.7...v3.3.1)

---
updated-dependencies:
- dependency-name: pylint
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* lint

* maxsplit

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: farmio <farmio@alphart.net>
  • Loading branch information
dependabot[bot] and farmio authored Oct 5, 2024
1 parent 0ef84c9 commit dfcccc3
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 16 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ disable = [
"too-many-instance-attributes",
"too-many-lines",
"too-many-locals",
"too-many-positional-arguments",
"too-many-public-methods",
"too-many-return-statements",
"too-many-statements",
Expand Down
2 changes: 1 addition & 1 deletion requirements_testing.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-r requirements_production.txt
pre-commit==3.8.0
pylint==3.2.7
pylint==3.3.1
pytest==8.3.3
pytest-cov==5.0.0
pytest-icdiff==0.9
Expand Down
2 changes: 1 addition & 1 deletion xknxproject/loader/application_program_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def load(
tree_iterator = ElementTree.iterparse(application_xml, events=("start",))
# get namespace from root element
_, elem = next(tree_iterator)
namespace = elem.tag.split("KNX")[0]
namespace = elem.tag.split("KNX", maxsplit=1)[0]
# define namespaced tag strings for faster comparison - ~15% faster
# than elem.tag.endswith("tagname") or elem.tag == f"{namespace}tagname"
ns_com_object = f"{namespace}ComObject"
Expand Down
8 changes: 5 additions & 3 deletions xknxproject/loader/project_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,9 @@ def __get_links_from_ets4(com_object: ElementTree.Element) -> list[str]:
ga_list = connectors.findall("{*}Send") + connectors.findall("{*}Receive")

# Remove the project ID from GA
return [ga.get("GroupAddressRefId", "").split("_")[1] for ga in ga_list]
return [
ga.get("GroupAddressRefId", "").split("_", maxsplit=1)[1] for ga in ga_list
]

@staticmethod
def __get_links_from_ets5(com_object: ElementTree.Element) -> list[str]:
Expand Down Expand Up @@ -451,7 +453,7 @@ def parse_space(

def parse_functions(self, node: ElementTree.Element) -> XMLFunction:
"""Parse a functions from the document."""
identifier = node.get("Id", "").split("_")[1]
identifier = node.get("Id", "").split("_", 1)[1]
project_uid = node.get("Puid")
function_type = node.get("Type", "")

Expand All @@ -468,7 +470,7 @@ def parse_functions(self, node: ElementTree.Element) -> XMLFunction:
for sub_node in node:
if sub_node.tag.endswith("GroupAddressRef"):
project_uid = sub_node.get("Puid")
ref_id = sub_node.get("RefId", "").split("_")[1]
ref_id = sub_node.get("RefId", "").split("_", 1)[1]

group_address_ref: XMLGroupAddressRef = XMLGroupAddressRef(
ref_id=ref_id,
Expand Down
18 changes: 10 additions & 8 deletions xknxproject/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
):
"""Initialize a group address."""
self.name = name
self.identifier = identifier.split("_")[1]
self.identifier = identifier.split("_", 1)[1]
self.raw_address = int(address)
self.project_uid = project_uid
self.description = description
Expand Down Expand Up @@ -84,9 +84,9 @@ def str_address(self) -> str:
if self.style == GroupAddressStyle.FREE:
return f"{self.range_start}...{self.range_end}"
if self.style == GroupAddressStyle.TWOLEVEL:
return XMLGroupAddress.str_address(self.range_start, self.style).split("/")[
0
]
return XMLGroupAddress.str_address(self.range_start, self.style).split(
"/", maxsplit=1
)[0]
if self.style == GroupAddressStyle.THREELEVEL:
start_address_token = XMLGroupAddress.str_address(
self.range_start, self.style
Expand Down Expand Up @@ -284,7 +284,7 @@ def resolve_channel_module_placeholders(
):
return

module_instance_ref = self.ref_id.split("_CH")[0]
module_instance_ref = self.ref_id.split("_CH", maxsplit=1)[0]
try:
module_instance = next(
mi
Expand Down Expand Up @@ -316,10 +316,10 @@ class ModuleInstance:

def __post_init__(self) -> None:
"""Set is_submodule based on the identifier."""
self.module_def_id = self.ref_id.split("_")[0]
self.module_def_id = self.ref_id.split("_", maxsplit=1)[0]
_submodule_match = re.search(r"(_SM-[^_]+)", self.identifier)
if _submodule_match is not None:
self.base_module = f"{self.identifier.split('_SM-')[0]}"
self.base_module = f"{self.identifier.split('_SM-', maxsplit=1)[0]}"
self.definition_id = f"{self.module_def_id}{_submodule_match.group()}"
else:
self.base_module = None
Expand Down Expand Up @@ -580,7 +580,9 @@ def _base_number_from_allocator(
base_number_argument,
)
return 0
module_instance_index = int(self.ref_id.split("_MI-")[1].split("_")[0])
module_instance_index = int(
self.ref_id.split("_MI-", maxsplit=1)[1].split("_", maxsplit=1)[0]
)
return allocator_object_base.start + (
allocator_size * (module_instance_index - 1)
)
Expand Down
4 changes: 2 additions & 2 deletions xknxproject/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def text_parameter_insert_module_instance(
if "_MD-" in text_parameter_ref_id and (
_module_ref := get_module_instance_part(instance_ref, next_id=instance_next_id)
):
_application_ref = text_parameter_ref_id.split("_MD-")[0]
_parameter_ref = text_parameter_ref_id.split("_P-")[1]
_application_ref = text_parameter_ref_id.split("_MD-", maxsplit=1)[0]
_parameter_ref = text_parameter_ref_id.rsplit("_P-", maxsplit=1)[-1]
return f"{_application_ref}_{_module_ref}_P-{_parameter_ref}"

return text_parameter_ref_id
2 changes: 1 addition & 1 deletion xknxproject/zip/extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _get_xml_namespace(project_zip: ZipFile) -> str:
def _get_schema_version(namespace: str) -> int:
"""Get the schema version of the project."""
try:
schema_version = int(namespace.split("/")[-1])
schema_version = int(namespace.rsplit("/", 1)[-1])
except ValueError:
_LOGGER.error("Could not parse schema version from %s", namespace)
raise UnexpectedFileContent("Could not parse schema version.") from None
Expand Down

0 comments on commit dfcccc3

Please sign in to comment.