You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of the problem, including code/CLI snippet
$ git status --short
M gitlab/v4/objects/container_registry.py
$ git commit
black....................................................................Passed
flake8...................................................................Passed
isort....................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1
gitlab/v4/objects/ldap.py:20: error: Function is missing a type annotation
gitlab/v4/objects/repositories.py:15: error: Function is missing a type annotation
gitlab/v4/objects/repositories.py:38: error: Function is missing a type annotation
...
Maybe the mypy hook could be configured to ignore missing annotations or warn instead of erring -- at least until the annotations are in place:
Thanks for opening the issue, we already had this reported but i forgot to open one!
Yeah, that would help although then people might get CI failures because pre-commit wouldn't catch issues in files where it already should check for it.
I think a better solution would be to replace the files list in our config with an exclude pattern because currently the pre-commit hook is probably overriding the default files list and hence fails.
I think a better solution would be to replace the files list in our config with an exclude pattern because currently the pre-commit hook is probably overriding the default files list and hence fails.
After some some digging around it seems that exclude has the same problem as files: positional command line arguments will override the configuration. From mypy's docs:
Note that [--exclude] flag only affects recursive discovery, that is, when mypy is discovering files within a directory tree or submodules of a package to check. If you pass a file or module explicitly it will still be checked.
One solution would be to mirror the files pattern in the pre-hook config. It's not a nice solution but it's the only one I have managed to come up with so far.
Activity
nejch commentedon Jul 1, 2021
Thanks for opening the issue, we already had this reported but i forgot to open one!
Yeah, that would help although then people might get CI failures because pre-commit wouldn't catch issues in files where it already should check for it.
I think a better solution would be to replace the
fileslist in our config with anexcludepattern because currently the pre-commit hook is probably overriding the default files list and hence fails.https://mypy.readthedocs.io/en/stable/config_file.html#confval-files
python-gitlab/.mypy.ini
Lines 1 to 2 in 85713bb
I will test this tonight but feel free to already open a PR if you get it to work :)
antti-mikael commentedon Jul 1, 2021
Sorry, I totally missed the
.mypy.ini. I'll see if I have the time to fiddle with this.antti-mikael commentedon Jul 19, 2021
After some some digging around it seems that
excludehas the same problem asfiles: positional command line arguments will override the configuration. From mypy's docs:One solution would be to mirror the
filespattern in the pre-hook config. It's not a nice solution but it's the only one I have managed to come up with so far.nejch commentedon Aug 1, 2021
I have something in #1562, not the prettiest either but it should now take whatever args
pre-committhrows at it and ignore errors where needed.