-
Notifications
You must be signed in to change notification settings - Fork 268
Allow TypeVar names to start with an underscore #246
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,8 +42,8 @@ | |||||||||||
| #: Okay | ||||||||||||
| Good = TypeVar("Good") | ||||||||||||
|
|
||||||||||||
| #: N808 | ||||||||||||
| __NotGood = TypeVar("__NotGood") | ||||||||||||
| #: Okay | ||||||||||||
| __Good = TypeVar("__Good") | ||||||||||||
|
||||||||||||
| __Good = TypeVar("__Good") | |
| _Good = TypeVar("_Good") | |
| #: N808 | |
| __NotGood = TypeVar("__NotGood") |
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.
I don't have strong feelings either way. I haven't had a case (personally) where I would use a leading underscore, but it appears others do this fairly often:
Leading double underscores exist but are uncommon, so I think that's a good argument against supporting them:
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.
I think the simplicity here is the attractive nuisance. I would probably bail on
if name.startswith("__")because again, what's being asked for in the original issue is a single leading underscore. Double leading underscores for this are something I think we should draw a firm line in the sand about. I also don't agree with_T_cobut am fine supporting it if someone can justify why they want a typevar that starts like that (aside from they're telling people tofrom <mod> import *which is just a bad reason to justify this).I think we can simplify a lot of this logic though, because in retrospect, we can do
I don't think the
__is ever something we should not alert on frankly. It causes lots of silly magical things in the background.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.
I also have some other overall improvements to this function that I'll save for another pull request.