Skip to content

Commit

Permalink
chore: fix ruff PLR5501 (#774)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nora-Olivia-Ammann committed Jan 30, 2024
1 parent 7902840 commit 1f88112
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Expand Up @@ -14,7 +14,6 @@ repos:
--ignore=PLR0913,
--ignore=PLR0915,
--ignore=PLR2004,
--ignore=PLR5501,
--ignore=PLW0603,
]
- id: ruff-format
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Expand Up @@ -91,9 +91,9 @@ markdownlint = """
--config .markdownlint.yml \
--ignore CHANGELOG.md "**/*.md"
"""
ruff-check = "ruff check . --ignore=A002,D101,D102,PLR0912,PLR0913,PLR0915,PLR2004,PLR5501,PLW0603"
ruff-check = "ruff check . --ignore=A002,D101,D102,PLR0912,PLR0913,PLR0915,PLR2004,PLW0603"
ruff-check-github = """
ruff check . --output-format=github --ignore=A002,D101,D102,PLR0912,PLR0913,PLR0915,PLR2004,PLR5501,PLW0603
ruff check . --output-format=github --ignore=A002,D101,D102,PLR0912,PLR0913,PLR0915,PLR2004,PLW0603
"""
ruff-format = "ruff format ."
mypy = "mypy ."
Expand Down
27 changes: 14 additions & 13 deletions src/dsp_tools/commands/project/models/context.py
Expand Up @@ -142,19 +142,20 @@ def add_context(self, prefix: str, iri: Optional[str] = None) -> None:
:param iri: The IRI that belongs to this context prefix
:return: None
"""
if iri is None:
if prefix in self.knora_ontologies:
return
if prefix in self.base_ontologies:
return
if prefix in self.common_ontologies:
self._context[prefix] = self.common_ontologies[prefix]
else:
if iri.endswith("#"):
iri = iri[:-1]
self._context[prefix] = OntoIri(iri, True)
else:
self._context[prefix] = OntoIri(iri, False)
match iri:
case None:
if prefix in self.knora_ontologies:
return
elif prefix in self.base_ontologies:
return
elif prefix in self.common_ontologies:
self._context[prefix] = self.common_ontologies[prefix]
case str():
if iri.endswith("#"):
iri = iri[:-1]
self._context[prefix] = OntoIri(iri, True)
else:
self._context[prefix] = OntoIri(iri, False)
self._rcontext[iri] = prefix

def iri_from_prefix(self, prefix: str) -> Optional[str]:
Expand Down
9 changes: 5 additions & 4 deletions src/dsp_tools/commands/xmlupload/models/xmlallow.py
Expand Up @@ -23,6 +23,7 @@ def __init__(self, node: etree._Element, project_context: ProjectContext) -> Non
XmlUploadError: If an upload fails
"""
tmp = node.attrib["group"].split(":")

sysgroups = ["UnknownUser", "KnownUser", "ProjectMember", "Creator", "ProjectAdmin", "SystemAdmin"]
if len(tmp) > 1:
if tmp[0]:
Expand All @@ -37,11 +38,11 @@ def __init__(self, node: etree._Element, project_context: ProjectContext) -> Non
if project_context.project_name is None:
raise XmlUploadError("Project shortcode has not been set in ProjectContext")
self._group = project_context.project_name + ":" + tmp[1]
elif tmp[0] in sysgroups:
self._group = "knora-admin:" + node.attrib["group"]
else:
if tmp[0] in sysgroups:
self._group = "knora-admin:" + node.attrib["group"]
else:
raise XmlUploadError(f'Group "{node.attrib["group"]}" is not known: ')
raise XmlUploadError(f'Group "{node.attrib["group"]}" is not known: ')

if not node.text:
raise XmlUploadError("No permission set specified")
self._permission = PermissionValue[node.text]
Expand Down
7 changes: 3 additions & 4 deletions src/dsp_tools/models/datetimestamp.py
Expand Up @@ -38,11 +38,10 @@ def __init__(self, val: Any):
self._dateTimeStamp = val
elif isinstance(val, DateTimeStamp):
self._dateTimeStamp = str(val)
elif val.get("@type") == "xsd:dateTimeStamp" and regex.search(self._validation_regex, str(val.get("@value"))):
self._dateTimeStamp = val["@value"]
else:
if val.get("@type") == "xsd:dateTimeStamp" and regex.search(self._validation_regex, str(val.get("@value"))):
self._dateTimeStamp = val["@value"]
else:
raise BaseError(f"Invalid xsd:dateTimeStamp: '{val}'")
raise BaseError(f"Invalid xsd:dateTimeStamp: '{val}'")

def __eq__(self, other: Union[str, "DateTimeStamp"]) -> bool:
if isinstance(other, str):
Expand Down

0 comments on commit 1f88112

Please sign in to comment.