Skip to content

Commit

Permalink
fix: support python 3.10, 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
JGrothoff committed Nov 28, 2024
1 parent 7986c4e commit 9e88490
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/pdf2aas/evaluation/aas.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Classes for the evaluation of pdf2aas conversion using Asset Administration Shells as input."""

import datetime
import json
import logging
import re
import shutil
from datetime import datetime, timezone
from pathlib import Path
from typing import ClassVar

Expand Down Expand Up @@ -222,7 +222,7 @@ def run_extraction(self) -> Path | None:
"""
run_path = None
if self.eval_path:
run_path = self.eval_path / datetime.datetime.now(tz=datetime.UTC).strftime(
run_path = self.eval_path / datetime.now(tz=timezone.utc).strftime(
"%Y-%m-%d_%H-%M-%S",
)
run_path.mkdir(parents=True, exist_ok=True)
Expand Down
6 changes: 3 additions & 3 deletions src/pdf2aas/generator/aas_technical_data_submodel.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Generator for Technical Data Submodels of Asset Administration Shells."""

import datetime
import json
import logging
import re
import uuid
from datetime import datetime, timezone
from typing import ClassVar

from basyx.aas import model
Expand Down Expand Up @@ -174,7 +174,7 @@ def _create_submodel_template(self) -> model.Submodel:
model.Property(
id_short="ValidDate",
value_type=model.datatypes.Date,
value=datetime.datetime.now(tz=datetime.UTC).date(),
value=datetime.now(tz=timezone.utc).date(),
category="PARAMETER",
semantic_id=self._create_semantic_id(
"https://admin-shell.io/ZVEI/TechnicalData/ValidDate/1/1",
Expand Down Expand Up @@ -403,7 +403,7 @@ def _create_aas_property_smc(
None,
),
)
except AASConstraintViolation as error:
except AASConstraintViolation as error: # noqa: PERF203
logger.warning(
"Couldn't add %s item to property %s: %s",
type(value),
Expand Down
8 changes: 4 additions & 4 deletions src/pdf2aas/model/property.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import re
import uuid
from dataclasses import dataclass, field
from typing import Any, Self
from typing import Any

from .property_definition import PropertyDefinition

Expand Down Expand Up @@ -109,16 +109,16 @@ def to_legacy_dict(self) -> dict[str, str | None]:
"name": self.definition_name,
}

@classmethod
def from_dict(cls, property_dict: dict) -> Self:
@staticmethod
def from_dict(property_dict: dict) -> "Property":
"""Parse a Property from a dictionary."""
label = property_dict.get("property")
if label is None:
label = property_dict.get("label")
if label is None:
label = ""

return cls(
return Property(
label,
property_dict.get("value"),
property_dict.get("unit"),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def setup_method(self) -> None:
def test_reset(self):
self.g.add_properties(test_property_list)
self.g.reset()
assert self.g.dumps() == f'"{'";"'.join(CSV.header)}"\n'
assert self.g.dumps() == ('"' +'";"'.join(CSV.header) + '"\n')
def test_dumps(self):
self.g.add_properties(test_property_list)
with(open('tests/assets/dummy-result.csv') as file):
Expand Down

0 comments on commit 9e88490

Please sign in to comment.