-
Notifications
You must be signed in to change notification settings - Fork 564
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
Fix errors reported by mypy #1330
Conversation
ba2bbeb
to
13aa36a
Compare
@ashleysommer have you used mypy anywhere? Do you think adding it to our requirements here is sensible? It is powerful but adds more dependencies |
@aucampia thank you very much for your effort here! Lots of cleanup and more types! Since rdflib is getting more and more types, having mypy seems a really good thing to me. |
Removed import of xml.etree.cElementTree as it was was deprecated in python 3.3. Also, since xml.etree.ElementTree has been a thing for a long time there is no good reason to try fallbacks if it fails to import.
Yes, I use MyPy in PySHACL and in the Sanic project, for static type analysis during CI build. It is indeed a very powerful and useful tool. I like using it, and I believe all new modern Python software projects should incorporate MyPy type checking from the start. However I'm not sure it makes sense to use it in the RDFLib project. A very large portion of contributors to RDFLib are not software engineers. One of the primary reasons that academics, researchers, and scientists use Python is because of the low barrier to entry, and one of those points of ease is the dynamic and untyped nature. We've seen in the past some contributors are frustrated by the existing PEP8 requirements and our preference (not requirement) for Black formatted code. Its a balancing act between having high quality code contributions, and having any contributions at all. Adding yet another barrier to contribution, another hurdle to jump, another dev-dependency to install, another required tool contributors have to learn and to use, sounds like a bad idea to me. Having said all that, I am in favour of the software engineers in our community to add the type annotations, run MyPy locally, and fix the errors it raises, then push those annotations and fixes as a PR. I don't think there is any need to add it to the CI pipelines. |
@ashleysommer I get the reluctance to add barriers to contribution. However there is another side to this which is that
And then there are some cases where type annotations that was present were wrong:
And with the current config of I will update the PR to just merge the type annotations and fixes for now. I would however like to keep the Would you be okay with just running |
Also move mypy config into `setup.cfg` to be in line with other tool configuration.
Pull request no longer adds |
We could just run mypy occasionally, i.e. not part of the automated build, but see my response and suggestion below.
OK, how about the reverse wetup to what @ashleysommer proposed:
This takes work of contributors and puts it on us maintainers, however the overhead will be very low after this initial PR that fixes all current mypy issues. We will only see any newly introduced errors. Doing things this way around means ad hoc contributors don't have to learn mypy but we will still get the benefit from applying it. Also, some of our contributors, such as @aucampia !! will indeed know all about mypy. @white-gecko @ashleysommer, what do you think of doing this this way around? |
I'll merge this as we benefit from the MyPy fixes and leave it to elsewhere to decide when/how to repeat MyPy enhancements. |
Fixes mypy errors
and add mypy to CI pipelinesProposed Changes
Add mypy to CI pipeline