Skip to content

Suggestions: check that the name is normalized #143962

@serhiy-storchaka

Description

@serhiy-storchaka

Feature or enhancement

Example:

>>> class A:
...     attrA = 1
...     attr𝔹 = 2
...     
>>> getattr(A, 'attrB')
2
>>> getattr(A, 'attr𝔹')
AttributeError: type object 'A' has no attribute 'attr𝔹'. Did you mean: 'attrA'?

The correct suggestion is 'attrB', not 'attrA'.

Every time Python outputs suggestion for the name, it should first check whether the name is normalized. If it is not, Python should check if the normalized name exists, and suggest the normalized version, otherwise suggest names similar to the normalized version. It may be tricky, because the normalized came can look exactly like not normalized name (for example, 'µ' ('\xb5') and 'μ' ('\u03bc')). So we need to output also the ascii() of the name in that case.

Linked PRs

Metadata

Metadata

Labels

3.15new features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-featureA feature request or enhancement

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions