Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TYP: Add a version stub to allow mypy to run without building #1210

Merged
merged 1 commit into from
Mar 7, 2023

Conversation

effigies
Copy link
Member

@effigies effigies commented Mar 2, 2023

Thanks to @Factral in #1208 (comment) I realized that we could probably make the contribution process a little nicer to people not wanting to pip install -e or hatch build --hooks-only just to make the pre-commit hooks run cleanly.

This adds a _version.pyi that mypy will respect without even checking whether _version.py is present.

The biggest potential risk is setuptools-scm changing the contents of _version.py in the future, but that seems low and a thing we can deal with if it comes up.

No need to backport unless we get contributors to a maintenance branch.

Verifying:
~/Projects/nipy git clone nibabel/.git nibabel-mypy-test
Cloning into 'nibabel-mypy-test'...
done.
~/Projects/nipy cd nibabel-mypy-test 
nibabel-mypy-test on typ/version_stub pre-commit install
pre-commit installed at .git/hooks/pre-commit
nibabel-mypy-test on typ/version_stub pre-commit run --all
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
check vcs permalinks.....................................................Passed
blue.....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
mypy.....................................................................Passed

Reverting to master:

git checkout master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Switched to a new branch 'master'
nibabel-mypy-test on master pre-commit run --all               
trim trailing whitespace.................................................Passed
fix end of files.........................................................Passed
check yaml...............................................................Passed
check json...............................................................Passed
check toml...............................................................Passed
check for added large files..............................................Passed
check for case conflicts.................................................Passed
check for merge conflicts................................................Passed
check vcs permalinks.....................................................Passed
blue.....................................................................Passed
isort....................................................................Passed
flake8...................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

nibabel/pkg_info.py:9: error: Cannot find implementation or library stub for module named "nibabel._version"  [import]
nibabel/pkg_info.py:9: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 107 source files)

@effigies effigies added this to the 5.1.0 milestone Mar 2, 2023
@codecov
Copy link

codecov bot commented Mar 2, 2023

Codecov Report

Patch coverage has no change and project coverage change: +0.08 🎉

Comparison is base (3a4cc5e) 92.06% compared to head (cf43308) 92.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1210      +/-   ##
==========================================
+ Coverage   92.06%   92.14%   +0.08%     
==========================================
  Files          97       97              
  Lines       12334    12334              
  Branches     2534     2534              
==========================================
+ Hits        11355    11365      +10     
+ Misses        655      647       -8     
+ Partials      324      322       -2     
Impacted Files Coverage Δ
nibabel/spatialimages.py 94.06% <0.00%> (+0.91%) ⬆️
nibabel/nicom/ascconv.py 90.12% <0.00%> (+2.46%) ⬆️
nibabel/testing/__init__.py 98.18% <0.00%> (+2.72%) ⬆️
nibabel/__init__.py 100.00% <0.00%> (+3.17%) ⬆️
nibabel/pydicom_compat.py 88.23% <0.00%> (+5.88%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@effigies effigies merged commit bbae9ed into nipy:master Mar 7, 2023
@effigies effigies deleted the typ/version_stub branch March 7, 2023 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant