jatkinson1000/archeryutils

Support and testing for python <= 3.7

jatkinson1000 opened this issue · 3 comments

As a result of #25 the minimum python version was set at 3.8 to satisfy the minimum numpy of 1.22, which in turn was required to pass mypy --strict (full type hinting support of internal functions was only added in numpy 1.22).

However, the code runs perfectly fine on python 3.7.

Can we remove mypy as a dependency and install/run it only during the CI process?
And if so can we set things up so that we run CI testing on python <= 3.7, but not mypy?

One Qn - if we do this how do we indicate this in documentation given we will be passing strict mypy, but only on certain versions?

I'd recommend keeping all developer stuff as an optional dependency in the pyproject.toml, and only putting necessary components in dependencies:

[project]

dependencies = [
    "numpy>=1.20.3",
]

[project.optional-dependencies]
test = [
    "pytest>=7.2.0",
]
lint = [
    "black>=22.12.0",
    "pylint",
    "flake8",
    "mypy>=1.0.0",
]

Then in the linter CI jobs you can replace pip install . with pip install .[lint]. I'd probably also keep mypy separate from testing, as a type checker failure doesn't necessarily mean the code doesn't work. I'd see no issue with running testing over a matrix of Python 3.7 -> 3.11, but running linters on just a single Python version (probably the latest one?).

Regarding the question about documenting the fact that strict mypy won't be verified on older versions: I personally wouldn't worry about it as long as your tests are passing. Python 3.7 is going out of support in a few months anyway.

Thanks.
Only comment is that there is now some code (the tests) that will not run with only the core dependencies installed.

Whilst this is nominally fine (don't need to run tests in deployment) it does mean that there is technically unrunnable code in a basic install.
Is this acceptable practice?

I think so. If people are installing from PyPI, they can still get the testing dependencies with pip install archeryutils[tests] if they want them, but in my experience people only tend to run the tests for projects they're actively contributing to.