Skip to content

Commit 20d7430

Browse files
authored
fix: replace deprecated package with Python 3.13 deprecated decorator (#537)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 791d652 commit 20d7430

File tree

9 files changed

+49
-25
lines changed

9 files changed

+49
-25
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464

6565
- name: Test docstrings with doctest
6666
if: "runner.os == 'Linux' && matrix.python-version == 3.11"
67-
run: python -m pytest --doctest-modules src/particle --ignore-glob="src/particle/particle/convert.py"
67+
run: python -m pytest --doctest-modules src/particle --ignore=src/particle/particle/convert.py
6868

6969
notebooks:
7070
runs-on: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
hooks:
3535
- id: mypy
3636
files: src
37-
additional_dependencies: [attrs==21.4.0, hepunits>=2.2.0, importlib_resources, types-deprecated]
37+
additional_dependencies: [attrs==21.4.0, hepunits>=2.2.0, importlib_resources]
3838
args: [--show-error-codes]
3939

4040
- repo: https://github.com/codespell-project/codespell

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ dependencies = [
4343
"attrs>=19.2",
4444
"hepunits>=2.0.0",
4545
"importlib-resources>=2.0;python_version<\"3.9\"",
46-
"typing-extensions;python_version<\"3.8\"",
47-
"deprecated"
46+
"typing-extensions>=4.5;python_version<\"3.13\"",
4847
]
4948
dynamic = ["version"]
5049

src/particle/_compat/__init__.py

Whitespace-only changes.

src/particle/_compat/typing.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2018-2023, Eduardo Rodrigues and Henry Schreiner.
2+
#
3+
# Distributed under the 3-clause BSD license, see accompanying file LICENSE
4+
# or https://github.com/scikit-hep/particle for details.
5+
6+
7+
from __future__ import annotations
8+
9+
import sys
10+
11+
if sys.version_info < (3, 8):
12+
from typing_extensions import Protocol, runtime_checkable
13+
else:
14+
from typing import Protocol, runtime_checkable
15+
16+
if sys.version_info < (3, 9):
17+
from importlib_resources.abc import Traversable
18+
elif sys.version_info < (3, 11):
19+
from importlib.abc import Traversable
20+
else:
21+
from importlib.resources.abc import Traversable
22+
23+
24+
__all__ = (
25+
"Protocol",
26+
"runtime_checkable",
27+
"Traversable",
28+
)

src/particle/_compat/warnings.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from __future__ import annotations
2+
3+
import sys
4+
5+
if sys.version_info < (3, 13):
6+
from typing_extensions import deprecated
7+
else:
8+
from warnings import deprecated
9+
10+
__all__ = ["deprecated"]

src/particle/particle/convert.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@
6363
import pandas as pd
6464

6565
from .. import data
66+
from .._compat.typing import Traversable
6667
from ..pdgid import PDGID, is_baryon
67-
from ..typing import StringOrIO, Traversable
68+
from ..typing import StringOrIO
6869
from .enums import (
6970
Charge,
7071
Charge_mapping,

src/particle/particle/particle.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,15 @@
1515

1616
# External dependencies
1717
import attr
18-
from deprecated import deprecated
1918
from hepunits.constants import c_light
2019

2120
from .. import data
21+
from .._compat.typing import Traversable
22+
from .._compat.warnings import deprecated
2223
from ..converters.evtgen import EvtGenName2PDGIDBiMap
2324
from ..pdgid import PDGID, is_valid
2425
from ..pdgid.functions import Location, _digit
25-
from ..typing import HasOpen, HasRead, StringOrIO, Traversable
26+
from ..typing import HasOpen, HasRead, StringOrIO
2627
from .enums import (
2728
Charge,
2829
Charge_mapping,
@@ -1240,8 +1241,7 @@ def findall(
12401241

12411242
@classmethod
12421243
@deprecated(
1243-
version="0.22",
1244-
reason="This method is deprecated and will be removed from version 0.23.0. Use finditer or findall instead.",
1244+
"This method is deprecated and will be removed from version 0.23.0. Use finditer or findall instead.",
12451245
)
12461246
def from_string(cls: type[Self], name: str) -> Self:
12471247
"Get a particle from a PDG style name - returns the best match."
@@ -1252,8 +1252,7 @@ def from_string(cls: type[Self], name: str) -> Self:
12521252

12531253
@classmethod
12541254
@deprecated(
1255-
version="0.22",
1256-
reason="This method is deprecated and will be removed from version 0.23.0. Use finditer or findall instead.",
1255+
"This method is deprecated and will be removed from version 0.23.0. Use finditer or findall instead.",
12571256
)
12581257
def from_string_list(cls: type[Self], name: str) -> list[Self]:
12591258
"Get a list of particles from a PDG style name."

src/particle/typing.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,11 @@
66

77
from __future__ import annotations
88

9-
import sys
109
from typing import Any, TextIO, Union
1110

12-
if sys.version_info < (3, 8):
13-
from typing_extensions import Protocol, runtime_checkable
14-
else:
15-
from typing import Protocol, runtime_checkable
16-
17-
if sys.version_info < (3, 9):
18-
from importlib_resources.abc import Traversable
19-
else:
20-
from importlib.abc import Traversable
21-
11+
from ._compat.typing import Protocol, Traversable, runtime_checkable
2212

2313
__all__ = (
24-
"Protocol",
25-
"runtime_checkable",
26-
"Traversable",
2714
"StringOrIO",
2815
"HasOpen",
2916
"HasRead",

0 commit comments

Comments
 (0)