Skip to content

Commit

Permalink
ENH: add Path to allowed load() arguments (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
redeboer authored Apr 25, 2024
1 parent 829f0b9 commit df1b60d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def create_constraints_inventory() -> None:
"NodeQuantumNumber": ("obj", "qrules.quantum_numbers.NodeQuantumNumber"),
"NodeType": "typing.TypeVar",
"ParticleWithSpin": ("obj", "qrules.particle.ParticleWithSpin"),
"Path": "pathlib.Path",
"qrules.topology.EdgeType": "typing.TypeVar",
"qrules.topology.NodeType": "typing.TypeVar",
"SpinFormalism": ("obj", "qrules.transition.SpinFormalism"),
Expand Down
4 changes: 2 additions & 2 deletions src/qrules/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def asdot(
return print_dot(instance)


def load(filename: str) -> object:
def load(filename: str | Path) -> object:
with open(filename) as stream:
file_extension = _get_file_extension(filename)
if file_extension == "json":
Expand Down Expand Up @@ -170,7 +170,7 @@ def write(instance: object, filename: str) -> None:
raise NotImplementedError(msg)


def _get_file_extension(filename: str) -> str:
def _get_file_extension(filename: str | Path) -> str:
path = Path(filename)
extension = path.suffix.lower()
if not extension:
Expand Down

0 comments on commit df1b60d

Please sign in to comment.