Skip to content

Commit

Permalink
feat: drop Python 2 (#57)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
henryiii and pre-commit-ci[bot] authored Jan 14, 2022
1 parent 128cba2 commit c15a570
Show file tree
Hide file tree
Showing 22 changed files with 1,438 additions and 97 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
fail-fast: false
matrix:
python-version:
- "2.7"
- "3.5"
- "3.6"
- "3.8"
- "3.9"
- "3.10"
Expand All @@ -46,5 +45,4 @@ jobs:
run: python -m pytest --doctest-modules --cov=src/hepunits --cov-report=xml

- name: Test coverage with Codecov
if: matrix.python-version != '3.5' && matrix.python-version != '3.8'
uses: codecov/codecov-action@v2
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,4 @@ docs/_build
/.mypy_cache/*
/pip-wheel-metadata/*
/src/hepunits/version.py
/src/hepunits/_version.py
47 changes: 37 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@

repos:
- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: mixed-line-ending
- id: requirements-txt-fixer
- id: trailing-whitespace
Expand All @@ -20,6 +14,17 @@ repos:
- id: check-symlinks
- id: check-yaml

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/psf/black
rev: 21.12b0
hooks:
- id: black-jupyter

- repo: https://github.com/mgedmin/check-manifest
rev: "0.47"
hooks:
Expand All @@ -36,10 +41,32 @@ repos:
rev: v0.931
hooks:
- id: mypy
args: [--strict]
files: src
args: [--show-error-codes]

- repo: https://github.com/asottile/pyupgrade
rev: v2.31.0
- repo: https://github.com/asottile/setup-cfg-fmt
rev: v1.20.0
hooks:
- id: pyupgrade
- id: setup-cfg-fmt

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort

- repo: https://github.com/codespell-project/codespell
rev: v2.1.0
hooks:
- id: codespell

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.9.0
hooks:
- id: python-check-blanket-noqa
- id: python-check-blanket-type-ignore
- id: python-no-log-warn
- id: python-no-eval
- id: python-use-type-annotations
- id: rst-backticks
- id: rst-directive-colons
- id: rst-inline-touching-normal
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ include pyproject.toml
recursive-include tests *.py

# Type support
recursive-include src py.typed
recursive-include src py.typed *.pyi

exclude .pre-commit-config.yaml codecov.yml
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ These simple rules are enough - exemplified in the code below:
- Dimensioned quantities in the "data stores" abide to the HEP system of units.

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

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

For the sake of argument, let's consider below a function returning a dimensioned quantity.
the function below stores a dimensioned quantity defined in keV
Expand Down
19 changes: 19 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import nox


@nox.session
def lint(session: nox.Session) -> None:
"""
Run the linter.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session(python=["3.6", "3.7", "3.8", "3.9", "3.10"])
def tests(session: nox.Session) -> None:
"""
Run the unit and regular tests.
"""
session.install(".[test]")
session.run("pytest", *session.posargs)
29 changes: 27 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,35 @@ requires = [
]
build-backend = "setuptools.build_meta"


[tool.setuptools_scm]
write_to = "src/hepunits/version.py"
write_to = "src/hepunits/_version.py"


[tool.isort]
profile = "black"


[tool.pytest.ini_options]
minversion = "6.0"
junit_family = "xunit2"
testpaths = ["tests"]
filterwarnings = ["error"]
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
log_cli_level = "DEBUG"


[tool.check-manifest]
ignore = [
"src/hepunits/version.py",
"src/hepunits/_version.py",
".pre-commit-config.yaml",
"noxfile.py",
]


[tool.mypy]
warn_unused_configs = true
python_version = "3.6"
files = ["src"]
strict = true
81 changes: 27 additions & 54 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,90 +1,63 @@
[bdist_wheel]
universal=1


[metadata]
name = hepunits
author = Eduardo Rodrigues
author_email = eduardo.rodrigues@cern.ch
maintainer = Eduardo Rodrigues
maintainer_email = eduardo.rodrigues@cern.ch
description = Units and constants in the HEP system of units
long_description = file: README.rst
long_description_content_type = text/x-rst
url = https://github.com/scikit-hep/hepunits
author = Eduardo Rodrigues
author_email = eduardo.rodrigues@cern.ch
maintainer = Eduardo Rodrigues
maintainer_email = eduardo.rodrigues@cern.ch
license = BSD-3-Clause
classifier =
Topic :: Scientific/Engineering
Intended Audience :: Science/Research
license_file = LICENSE
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
Operating System :: OS Independent
Intended Audience :: Science/Research
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 2.7
Programming Language :: Python :: 3
Programming Language :: Python :: 3.5
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Development Status :: 5 - Production/Stable
Topic :: Scientific/Engineering
keywords =
HEP
HEP system of units
Units
Constants


[options]
python_requires = >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*
packages = find:
python_requires = >=3.6
include_package_data = True
zip_safe = False
packages: find:
package_dir =
=src


zip_safe = False

[options.packages.find]
where = src


[options.package_data]
* = py.typed

[tool:pytest]
junit_family=xunit2
testpaths =
tests
addopts = -Wd


[options.extras_require]
test =
pytest >=4.6
pytest-cov >=2.8.0
dev =
pytest >=4.6
pytest-cov >=2.8.0
all =
pytest >=4.6
pytest-cov >=2.8.0

[check-manifest]
ignore =
src/hepunits/version.py
.pre-commit-config.yaml

[mypy]
strict=True

[mypy-hepunits.version]
ignore_missing_imports = True
pytest>=6
pytest-cov>=2.8.0
dev =
pytest>=6
pytest-cov>=2.8.0
test =
pytest>=6
pytest-cov>=2.8.0

[options.package_data]
* = py.typed

[flake8]
max-complexity = 12
ignore = E203, E231, E501, E722, W503, F401, F403, F405
extend-ignore = B950, E501
select = C,E,F,W,B,B9,T
per-file-ignores =
tests/*: T, F405, F403
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Licensed under a 3-clause BSD style license, see LICENSE.

from setuptools import setup
Expand Down
Loading

0 comments on commit c15a570

Please sign in to comment.