Skip to content

Commit

Permalink
Fix mypy pre-commit settings
Browse files Browse the repository at this point in the history
When proposing python#147 I noticed that mypy failed with missing
`types-request` - and while the mypy configuration had
the `--install-types`, it did not work automatically for requests.

The error was:

```
cherry_picker/cherry_picker.py:15: error: Library stubs not installed for
"requests"  [import-untyped]
    import requests
    ^
cherry_picker/cherry_picker.py:15: note: Hint: "python3 -m pip install types-requests"
cherry_picker/cherry_picker.py:15: note: (or run "mypy --install-types" to install all missing stub packages)
cherry_picker/cherry_picker.py:15: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
```

I looked a bit closer and noticed the advice from
https://github.com/pre-commit/mirrors-mypy

> Note that using the --install-types is problematic. Mutating the
pre-commit environment at runtime breaks cache and will break parallel
builds.

This PR fixes the problem by removing `--install-types` and installing
types-requests explicitly as additional-dependencies.

starting
  • Loading branch information
potiuk committed Nov 17, 2024
1 parent 34d27eb commit 560605d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ repos:
args:
[
--ignore-missing-imports,
--install-types,
--non-interactive,
--pretty,
--show-error-codes,
.,
]
pass_filenames: false
additional_dependencies: ["types-requests"]

- repo: https://github.com/tox-dev/pyproject-fmt
rev: 2.2.4
Expand Down

0 comments on commit 560605d

Please sign in to comment.