Skip to content

Commit c15a570

Browse files
feat: drop Python 2 (#57)
* feat: drop Python 2 Fixes static typing support from outer layers - only full paths were supported before. Since this doesn't change often, listing things out is the best static solution. Added tests to make sure nothing gets missed and everything is included and remembered when anything gets changed or added. Added noxfile for easy running. Extended static checks. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 128cba2 commit c15a570

22 files changed

+1438
-97
lines changed

.github/workflows/main.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
python-version:
27-
- "2.7"
28-
- "3.5"
27+
- "3.6"
2928
- "3.8"
3029
- "3.9"
3130
- "3.10"
@@ -46,5 +45,4 @@ jobs:
4645
run: python -m pytest --doctest-modules --cov=src/hepunits --cov-report=xml
4746

4847
- name: Test coverage with Codecov
49-
if: matrix.python-version != '3.5' && matrix.python-version != '3.8'
5048
uses: codecov/codecov-action@v2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ docs/_build
7171
/.mypy_cache/*
7272
/pip-wheel-metadata/*
7373
/src/hepunits/version.py
74+
/src/hepunits/_version.py

.pre-commit-config.yaml

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11

22
repos:
3-
- repo: https://github.com/psf/black
4-
rev: 21.12b0
5-
hooks:
6-
- id: black
7-
83
- repo: https://github.com/pre-commit/pre-commit-hooks
94
rev: v4.1.0
105
hooks:
116
- id: debug-statements
127
- id: end-of-file-fixer
13-
- id: fix-encoding-pragma
148
- id: mixed-line-ending
159
- id: requirements-txt-fixer
1610
- id: trailing-whitespace
@@ -20,6 +14,17 @@ repos:
2014
- id: check-symlinks
2115
- id: check-yaml
2216

17+
- repo: https://github.com/asottile/pyupgrade
18+
rev: v2.31.0
19+
hooks:
20+
- id: pyupgrade
21+
args: [--py36-plus]
22+
23+
- repo: https://github.com/psf/black
24+
rev: 21.12b0
25+
hooks:
26+
- id: black-jupyter
27+
2328
- repo: https://github.com/mgedmin/check-manifest
2429
rev: "0.47"
2530
hooks:
@@ -36,10 +41,32 @@ repos:
3641
rev: v0.931
3742
hooks:
3843
- id: mypy
39-
args: [--strict]
4044
files: src
45+
args: [--show-error-codes]
4146

42-
- repo: https://github.com/asottile/pyupgrade
43-
rev: v2.31.0
47+
- repo: https://github.com/asottile/setup-cfg-fmt
48+
rev: v1.20.0
4449
hooks:
45-
- id: pyupgrade
50+
- id: setup-cfg-fmt
51+
52+
- repo: https://github.com/PyCQA/isort
53+
rev: 5.10.1
54+
hooks:
55+
- id: isort
56+
57+
- repo: https://github.com/codespell-project/codespell
58+
rev: v2.1.0
59+
hooks:
60+
- id: codespell
61+
62+
- repo: https://github.com/pre-commit/pygrep-hooks
63+
rev: v1.9.0
64+
hooks:
65+
- id: python-check-blanket-noqa
66+
- id: python-check-blanket-type-ignore
67+
- id: python-no-log-warn
68+
- id: python-no-eval
69+
- id: python-use-type-annotations
70+
- id: rst-backticks
71+
- id: rst-directive-colons
72+
- id: rst-inline-touching-normal

MANIFEST.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ include pyproject.toml
55
recursive-include tests *.py
66

77
# Type support
8-
recursive-include src py.typed
8+
recursive-include src py.typed *.pyi
99

1010
exclude .pre-commit-config.yaml codecov.yml

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ These simple rules are enough - exemplified in the code below:
136136
- Dimensioned quantities in the "data stores" abide to the HEP system of units.
137137

138138
- All definitions of dimensioned quantities are dimensioned by multiplying by the units,
139-
as in `mass_window = 500 * keV`.
139+
as in ``mass_window = 500 * keV``.
140140

141141
- All output of dimensioned quantities is converted to the required units
142-
by dividing by the units, as in `energy_resolution() / GeV`.
142+
by dividing by the units, as in ``energy_resolution() / GeV``.
143143

144144
For the sake of argument, let's consider below a function returning a dimensioned quantity.
145145
the function below stores a dimensioned quantity defined in keV

noxfile.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import nox
2+
3+
4+
@nox.session
5+
def lint(session: nox.Session) -> None:
6+
"""
7+
Run the linter.
8+
"""
9+
session.install("pre-commit")
10+
session.run("pre-commit", "run", "--all-files", *session.posargs)
11+
12+
13+
@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"])
14+
def tests(session: nox.Session) -> None:
15+
"""
16+
Run the unit and regular tests.
17+
"""
18+
session.install(".[test]")
19+
session.run("pytest", *session.posargs)

pyproject.toml

+27-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,35 @@ requires = [
66
]
77
build-backend = "setuptools.build_meta"
88

9+
910
[tool.setuptools_scm]
10-
write_to = "src/hepunits/version.py"
11+
write_to = "src/hepunits/_version.py"
12+
13+
14+
[tool.isort]
15+
profile = "black"
16+
17+
18+
[tool.pytest.ini_options]
19+
minversion = "6.0"
20+
junit_family = "xunit2"
21+
testpaths = ["tests"]
22+
filterwarnings = ["error"]
23+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
24+
xfail_strict = true
25+
log_cli_level = "DEBUG"
26+
1127

1228
[tool.check-manifest]
1329
ignore = [
14-
"src/hepunits/version.py",
30+
"src/hepunits/_version.py",
31+
".pre-commit-config.yaml",
32+
"noxfile.py",
1533
]
34+
35+
36+
[tool.mypy]
37+
warn_unused_configs = true
38+
python_version = "3.6"
39+
files = ["src"]
40+
strict = true

setup.cfg

+27-54
Original file line numberDiff line numberDiff line change
@@ -1,90 +1,63 @@
1-
[bdist_wheel]
2-
universal=1
3-
4-
51
[metadata]
62
name = hepunits
7-
author = Eduardo Rodrigues
8-
author_email = [email protected]
9-
maintainer = Eduardo Rodrigues
10-
maintainer_email = [email protected]
113
description = Units and constants in the HEP system of units
124
long_description = file: README.rst
135
long_description_content_type = text/x-rst
146
url = https://github.com/scikit-hep/hepunits
7+
author = Eduardo Rodrigues
8+
author_email = [email protected]
9+
maintainer = Eduardo Rodrigues
10+
maintainer_email = [email protected]
1511
license = BSD-3-Clause
16-
classifier =
17-
Topic :: Scientific/Engineering
18-
Intended Audience :: Science/Research
12+
license_file = LICENSE
13+
classifiers =
14+
Development Status :: 5 - Production/Stable
1915
Intended Audience :: Developers
20-
Operating System :: OS Independent
16+
Intended Audience :: Science/Research
2117
License :: OSI Approved :: BSD License
18+
Operating System :: OS Independent
2219
Programming Language :: Python
23-
Programming Language :: Python :: 2
24-
Programming Language :: Python :: 2.7
2520
Programming Language :: Python :: 3
26-
Programming Language :: Python :: 3.5
21+
Programming Language :: Python :: 3 :: Only
2722
Programming Language :: Python :: 3.6
2823
Programming Language :: Python :: 3.7
2924
Programming Language :: Python :: 3.8
3025
Programming Language :: Python :: 3.9
3126
Programming Language :: Python :: 3.10
32-
Development Status :: 5 - Production/Stable
27+
Topic :: Scientific/Engineering
3328
keywords =
3429
HEP
3530
HEP system of units
3631
Units
3732
Constants
3833

39-
4034
[options]
41-
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
35+
packages = find:
36+
python_requires = >=3.6
4237
include_package_data = True
43-
zip_safe = False
44-
packages: find:
4538
package_dir =
4639
=src
47-
48-
40+
zip_safe = False
4941

5042
[options.packages.find]
5143
where = src
5244

53-
54-
[options.package_data]
55-
* = py.typed
56-
57-
[tool:pytest]
58-
junit_family=xunit2
59-
testpaths =
60-
tests
61-
addopts = -Wd
62-
63-
6445
[options.extras_require]
65-
test =
66-
pytest >=4.6
67-
pytest-cov >=2.8.0
68-
dev =
69-
pytest >=4.6
70-
pytest-cov >=2.8.0
7146
all =
72-
pytest >=4.6
73-
pytest-cov >=2.8.0
74-
75-
[check-manifest]
76-
ignore =
77-
src/hepunits/version.py
78-
.pre-commit-config.yaml
79-
80-
[mypy]
81-
strict=True
82-
83-
[mypy-hepunits.version]
84-
ignore_missing_imports = True
47+
pytest>=6
48+
pytest-cov>=2.8.0
49+
dev =
50+
pytest>=6
51+
pytest-cov>=2.8.0
52+
test =
53+
pytest>=6
54+
pytest-cov>=2.8.0
8555

56+
[options.package_data]
57+
* = py.typed
8658

8759
[flake8]
88-
max-complexity = 12
89-
ignore = E203, E231, E501, E722, W503, F401, F403, F405
60+
extend-ignore = B950, E501
9061
select = C,E,F,W,B,B9,T
62+
per-file-ignores =
63+
tests/*: T, F405, F403

setup.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# Licensed under a 3-clause BSD style license, see LICENSE.
43

54
from setuptools import setup

0 commit comments

Comments
 (0)