average-father-89924
03/17/2023, 12:27 PMpants check my_file.py
mypy raises things that I expect - great!
I now configured a pre-commit hook as such:
repos:
- repo: local
hooks:
- id: check
name: check
entry: pants check
language: system
files: ^.*.(py|pyi)$When I now git add and git commit the same file mypy fails with this error:
.cache/pex_root/venvs/5cb0b2dcd2357da2bbde0d877bde9b817c555a3e/fde49d60105c0ef9833901ddf249f36d7deded9a/lib/python3.11/site-packages/numpy/__init__.pyi641 error: Positional-only parameters are only supported in Python 3.8 and greaterThis problem comes from an old mypy version and should be already fixed (ref). I am puzzled where this discrepancy of different mypy version stems from and would be excited if someone could help me out here!
refined-addition-53644
03/17/2023, 1:08 PMpants check ::
refined-addition-53644
03/17/2023, 1:11 PM[mypy]
with custom version like this
[mypy]
version = "mypy==1.1.1"
lockfile = "<your_custom_path">
average-father-89924
03/17/2023, 1:15 PM[mypy]
version = "mypy==1.1.1"
args = ["--non-interactive", "--install-types"]
extra_type_stubs = ["types-requests==2.25.12"]
# Set this to a path, then run.pants generate-lockfiles --resolve=mypy-extra-type-stubs
extra_type_stubs_lockfile = "3rdparty/python/mypy_extra_type_stubs.lock"
lockfile = "3rdparty/mypy_lockfile.txt"and I ran
pants generate-lockfiles ::
and pants export::
. pants check ::
runs successfully.refined-addition-53644
03/17/2023, 1:16 PMaverage-father-89924
03/17/2023, 1:17 PM[python]
tailor_pex_binary_targets = false
interpreter_constraints = ["CPython==3.11.2"]
enable_resolves = true
refined-addition-53644
03/17/2023, 1:18 PMaverage-father-89924
03/17/2023, 1:18 PMrefined-addition-53644
03/17/2023, 1:20 PM.cache/pex_root/venvs/5cb0b2dcd2357da2bbde0d877bde9b817c555a3e/fde49d60105c0ef9833901ddf249f36d7deded9a/lib/python3.11/site-packages/numpy/__init__.pyi:641: error: Positional-only parameters are only supported in Python 3.8 and greater
average-father-89924
03/17/2023, 1:20 PMrefined-addition-53644
03/17/2023, 1:22 PMpex_root
but there are more
https://www.pantsbuild.org/docs/using-pants-in-cirefined-addition-53644
03/17/2023, 1:24 PMentry
in the hook so that it only runs on the changed files not your whole repo whenever you commit
pants \
--changed-since=origin/main \
--changed-dependees=transitive check
average-father-89924
03/17/2023, 1:36 PMrefined-addition-53644
03/17/2023, 1:37 PMpass_filenames: false
- repo: local
hooks:
- id: lint-check
name: Checking source files formatting
entry: "./pants --changed-since=main --changed-dependees=transitive lint"
language: script
types: [python]
pass_filenames: false
verbose: true
average-father-89924
03/17/2023, 1:38 PM