-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow redefinition of underscore functions (#10811)
This PR causes mypy to not show an error if a function named _ is redefined, as a single underscore is often used as a name for a throwaway function. This handles the case where _ is used as an alias for gettext by differentiating between functions that are aliased as _ but defined with another name, and functions that are defined as _. Overwriting a function named _ is allowed, but overwriting a function named something else but aliased as _ is not allowed, which should prevent people from accidentally overwriting gettext after importing it. This also turns calling a function named _ directly into an error, as currently we keep track of the type of the first definition if there are multiple functions defined as _, instead of the type of the last definition, and functions are usually not meant to be called directly if they're named _.
- Loading branch information
1 parent
d0bd1c8
commit ed09f8d
Showing
6 changed files
with
100 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters