-
Notifications
You must be signed in to change notification settings - Fork 1
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
Strict requirement for type hinting #83
Conversation
It looks like |
It looks like we should be able to use |
Yeah I wasn't sure whether or not requiring type hints on testing code is desirable, but that can be changed if we decide that it isn't |
I have had a look at this, because my next PR (#84) is affected. We can include the code below in def pytest_configure(config):
plugin = config.pluginmanager.getplugin("mypy")
plugin.mypy_argv.append("--allow-untyped-calls")
plugin.mypy_argv.append("--allow-untyped-defs")
plugin.mypy_argv.append("--allow-incomplete-defs") I think this is probably worth doing - I guess it is a similar argument to whether or not you use docstrings. I think docstrings are worthwhile because it is the 'right' place to comment on tests when needed, but I'm not sure we need to enforce typing on tests. @dalonsoa and @alexdewar ? |
I think that being more relaxed with typing in the tests make sense, so if there is a way of removing the most annoying aspects of mypy there, as it seems there is, I would use it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. With that feedback, I'd say we roll back the typing added in tests
and then add the local pytest-mypy
plugin configuration to conftest.py
.
I agree. The only caveat I would add though is that if it ends up being a faff to exclude the |
Actually appears to be fairly straightforward to add module/folder level exclusions for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That config solution looks good - a bit cleaner! I've applied this branch to #84 and it works, so I'm happy to approve this.
Description
Based on the discussion in #60 it seems like a good idea to make type annotations mandatory. If this becomes a problem down the we can always switch to a less strict option, but if we are going to use a more strict option, switching to it down the line would be a nightmare (there already were a lot of extra
mypy
errors to fix with our currently pretty minimal code base).I could find type stubs for either
shapely
ordpath
, so turned off type checking when I imported them. I may not have been looking in the right places for them though. So, if anyone knows where they can be found, let me know.Type of change
Key checklist
pre-commit
checks:$ pre-commit run -a
$ poetry run pytest
Further checks