New setting "user_builtins_name": Ignore specific "name-defined" errors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Feature
Adding a setting "user_builtins_name", or "builtins", that is a array of strings for which the error [name-defined] is ignored.
Pitch
It is possible to extend the list of builtins function, which can be very useful in some projects as we no longer need to import this function if it's used extensively in the rest of the project.
Example:
builtins.__dict__['prints'] = prints = PrefixedPrint()
builtins.__dict__['_'] = localization.gettext
Sadly, mypy don't support such exotic things. There is two solution:
- Analyzer all the code to add dynamically the "user builtins name"
- Add a user-controlled setting to globally ignore specific "name-defined" errors
The first would be the best, but also the harder to implement. The second would be easier to implement, but some ignored 'name-defined' error could be legitimate depending on the import and call stack. But since the very exotic and niche feature, the risks are low and we can assume that the user know what he do when he use this settings.
The use of a setting name that contain the word 'builtins' allows to explicitly specify the user case of such setting (when a generic "ignore_name_defined" could be misinterpreted and so misused)
Related Issues
#7931
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing related issue #7931 and mypy's existing configuration handling for name-defined diagnostics. Trace where these errors are produced and how settings are tested; done means a user-controlled builtins-name setting suppresses only the specified errors and is covered by appropriate tests and documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100