Skip to content

Commit

Permalink
FIX: support Python 3.9 again (#316)
Browse files Browse the repository at this point in the history
* DX: remove `setuptools-scm` version configuration
* MAINT: update hashes for Python < 3.11
* MAINT: update lock files
* MAINT: removed version constraints for dependencies
  • Loading branch information
grayson-helmholz authored Jan 17, 2025
1 parent a15a6e9 commit a38e867
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 87 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repos:
- id: check-useless-excludes

- repo: https://github.com/ComPWA/policy
rev: 0.5.15
rev: 0.5.16
hooks:
- id: check-dev-files
args:
Expand Down Expand Up @@ -60,7 +60,7 @@ repos:
metadata.vscode
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.9.1
rev: v0.9.2
hooks:
- id: ruff
args: [--fix]
Expand Down Expand Up @@ -122,7 +122,7 @@ repos:
pass_filenames: false

- repo: https://github.com/streetsidesoftware/cspell-cli
rev: v8.17.0
rev: v8.17.1
hooks:
- id: cspell

Expand All @@ -148,11 +148,11 @@ repos:
- python

- repo: https://github.com/ComPWA/pyright-pre-commit
rev: v1.1.391
rev: v1.1.392
hooks:
- id: pyright

- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.5.18
rev: 0.5.20
hooks:
- id: uv-lock
9 changes: 0 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ namespaces = false
where = ["src"]

[tool.setuptools_scm]
local_scheme = "no-local-version"
version_scheme = "only-version"
write_to = "src/qrules/version.py"

[tool.coverage.run]
Expand Down Expand Up @@ -537,10 +535,3 @@ commands = [
],
]
description = "Run ALL tests, including the slow channel tests, and compute coverage"

[tool.uv]
constraint-dependencies = [
"pygments!=2.19.*", # https://github.com/felix-hilden/sphinx-codeautolink/issues/152
"pytest-profiling!=1.8.0",
"sphinx-codeautolink!=0.16.0",
]
5 changes: 2 additions & 3 deletions src/qrules/io/_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from fractions import Fraction
from functools import singledispatch
from inspect import isfunction
from types import NoneType
from typing import TYPE_CHECKING, Any, cast

import attrs
Expand Down Expand Up @@ -299,11 +298,11 @@ def as_string(obj: Any) -> str:
>>> as_string(10)
'new int rendering'
"""
_LOGGER.warning(f"No DOT renderer implemented type {type(obj).__name__}")
if obj is not None:
_LOGGER.warning(f"No DOT renderer implemented type {type(obj).__name__}")
return str(obj)


@as_string.register(NoneType)
@as_string.register(int)
@as_string.register(float)
@as_string.register(str)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,6 @@ def _compute_hash(obj) -> str:


def _to_bytes(obj) -> bytes:
if isinstance(obj, bytes | bytearray):
if isinstance(obj, (bytes, bytearray)):
return obj
return pickle.dumps(obj)
18 changes: 13 additions & 5 deletions tests/unit/test_transition.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pyright: reportUnusedImport=false
import hashlib
import pickle # noqa: S403
import sys
from copy import deepcopy
from fractions import Fraction

Expand Down Expand Up @@ -47,10 +48,17 @@ def test_hash(self, reaction: ReactionInfo):
assert hash(deepcopy(reaction)) == hash(reaction)

def test_hash_value(self, reaction: ReactionInfo):
expected_hash = {
"canonical-helicity": "65106a44301f9340e633d09f66ad7d17",
"helicity": "9646d3ee5c5e8534deb8019435161f2e",
}[reaction.formalism]
if sys.version_info >= (3, 11):
expected_hash = {
"canonical-helicity": "65106a44301f9340e633d09f66ad7d17",
"helicity": "9646d3ee5c5e8534deb8019435161f2e",
}[reaction.formalism]
else:
expected_hash = {
"canonical-helicity": "0d8bc378677986e0dc2d3b02f5627e0b",
"helicity": "71404ad43550850a02109e8db044bd28",
}[reaction.formalism]

assert _compute_hash(reaction) == expected_hash


Expand Down Expand Up @@ -124,6 +132,6 @@ def _compute_hash(obj) -> str:


def _to_bytes(obj) -> bytes:
if isinstance(obj, bytes | bytearray):
if isinstance(obj, (bytes, bytearray)):
return obj
return pickle.dumps(obj)
Loading

0 comments on commit a38e867

Please sign in to comment.