Skip to content

Commit 9daa581

Browse files
authored
build: update to pybind11 3, modernize python (#294)
* update to pybind11 3 * update mypy, adjust typing
1 parent fd69c2e commit 9daa581

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ repos:
2727
rev: v2.31.0
2828
hooks:
2929
- id: pyupgrade
30-
args: ["--py36-plus"]
30+
args: ["--py38-plus"]
3131

3232
- repo: https://github.com/pycqa/flake8
3333
rev: 7.0.0
@@ -37,7 +37,7 @@ repos:
3737
additional_dependencies: [flake8-bugbear, flake8-print]
3838

3939
- repo: https://github.com/pre-commit/mirrors-mypy
40-
rev: v1.4.1
40+
rev: v1.17.1
4141
hooks:
4242
- id: mypy
4343
files: src

pybind11

Submodule pybind11 updated 252 files

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ convert = [
7272
"scipy",
7373
]
7474

75+
[tool.mypy]
76+
python_version = "3.9"
77+
7578
[project.scripts]
7679
correction = "correctionlib.cli:main"
7780

src/correctionlib/schemav1.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
1-
import sys
2-
from typing import List, Optional, Union
1+
from typing import List, Literal, Optional, Union
32

43
from pydantic import BaseModel, ConfigDict
54

6-
if sys.version_info >= (3, 8):
7-
from typing import Literal
8-
else:
9-
from typing_extensions import Literal
10-
11-
125
VERSION = 1
136

147

src/correctionlib/schemav2.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@
2222

2323
if sys.version_info >= (3, 9):
2424
from typing import Annotated, Literal
25-
elif sys.version_info >= (3, 8):
25+
else:
2626
from typing import Literal
2727

2828
from typing_extensions import Annotated
29-
else:
30-
from typing_extensions import Annotated, Literal
3129

3230

3331
VERSION = 2

src/correctionlib/util.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import importlib.resources
12
import pathlib
23
import sys
34

@@ -10,6 +11,11 @@ def this_module_path() -> pathlib.Path:
1011
import pkg_resources
1112

1213
return pathlib.Path(pkg_resources.resource_filename("correctionlib", ""))
13-
import importlib.resources
1414

15-
return importlib.resources.files("correctionlib")
15+
# get a real path out of the traversable
16+
paths = [
17+
p
18+
for p in importlib.resources.files("correctionlib").iterdir()
19+
if isinstance(p, pathlib.Path)
20+
]
21+
return pathlib.Path(paths[0].parent)

0 commit comments

Comments
 (0)