pcparadise / discordbot

GNU General Public License v3.0
3 stars 5 forks source link

Type hints? #27

Closed awsomearvinder closed 2 years ago

awsomearvinder commented 3 years ago

This project's existed for a little bit now although it still isn't really a thing yet. Do we want to take a strong stance on type hints?

CC: @lukadd16 @Ganoosh

awsomearvinder commented 3 years ago

I added a new branch called type-hints which I added type information based off of the current main branch. This issue is moreso if we want to allow and/or enforce type hints. I'm personally in favor of allowing type hints, although I don't think I'd want to enforce them as of yet just simply due to the lack of linting for types and increasing the barrier to entry.

lukadd16 commented 3 years ago

I haven't delved into type hints too much myself, but I do see merit in having them (I can recall many instances where Discord.py's code wasn't type-hinted, making using said code a less efficient process). Should we allow type hints? Absolutely. Should we enforce type hints for all code contributions? I'm impartial on this one. You raise a valid point about type hinting being a potential barrier to somebody making a certain types of contributions, so perhaps our policy could be "don't require type hinted code from PR authors but keep a to-do list of code that needs to be type-hinted at some point in the future".

awsomearvinder commented 3 years ago

That's kind of what I was thinking, especially as stuff like generics in python are rather weird. (Check help.py's find() method for example). Is the Item type always the same? What about if you have a class that holds a T and methods that take the T in? In that case you want the T to always be the same for the instance of the class, will it be? What about features like dependant types and ADTs like Union[]?

I am a huge proponent of static typing myself, actually wanting either typescript or python with type hints for projects, I just wanted everyone else's opinion. My personal opinion is that I'd want type hints on any "easy" type, but only encourage them on the harder stuff.