pylint-dev / pylint

It's not just a linter that annoys you!
https://pylint.readthedocs.io/en/latest/
GNU General Public License v2.0
5.28k stars 1.13k forks source link

Adding typehints to ``checkers`` module #4530

Closed yushao2 closed 3 years ago

yushao2 commented 3 years ago

Is your feature request related to a problem? Please describe

Many source files are still not typed

Describe the solution you'd like

Maybe we can start with the checkers module and adding typehints file by file and gradually the entire project. I'm not too sure if it would cause any regressions, but I think it might be a good idea and possibly an easy first issue for newcomers

Pierre-Sassoulas commented 3 years ago

I think it might be a good idea and possibly an easy first issue for newcomers

Theoretically, yes. practically there are questionable designs all around and actually doing this would force a refactor in order to not have circular imports revealed by the typing. As an example BaseChecker are registering MessageDefinition in a function and MessageDefinition are registering BaseChecker in another function. We could want to make the message namespace depend on nothing else, but in the messages namespace we also have the MessageHandlerMixin that is a Pylinter in disguise and depend on a lot of other classes and it would need to be moved. That's just an example, there might be more surprise along the way in other packages. (I started to add typing to pylint.messages I'll open a merge request for the easy part).

I think this is somewhat related to the NameTuple change to MSGS in checker we talked about in https://github.com/PyCQA/pylint/pull/4517#discussion_r641971927. This is almost something that would make a breaking change and require a design committee :sweat_smile:. There's some huge refactor and simplification to do.

Pierre-Sassoulas commented 3 years ago

I'm not against the idea, that would actually be great, but it's probably not something for a newcomer. Or one with some serious grit :smile:

yushao2 commented 3 years ago

I'm not against the idea, that would actually be great, but it's probably not something for a newcomer. Or one with some serious grit

i'll probably try some of the easy ones and make MRs for them, after I'm done with figuring out what's the issue with python 3.6 and visit_await that doesn't seem to be working :sweat_smile:

DanielNoord commented 3 years ago

This issue is basically a duplicate of #2079.

I think it would be good to create one mega-issue with a clear task list to streamline and guide the typing efforts. I don't have a clear vision right now, but some of the long-term maintainers might have a list of stuff they would like to see typed first to make maintaining and working on pylint easier. Things like that could be indicated if we manage/streamline the typing efforts a little bit more.

Pierre-Sassoulas commented 3 years ago

Closing as duplicate of #2079