MCPcopy Index your code
hub / github.com/python/mypy / get_unique_redefinition_name

Function get_unique_redefinition_name

mypy/util.py:476–489  ·  view source on GitHub ↗

Get a simple redefinition name not present among existing. For example, for name 'foo' we try 'foo-redefinition', 'foo-redefinition2', 'foo-redefinition3', etc. until we find one that is not in existing.

(name: str, existing: Container[str])

Source from the content-addressed store, hash-verified

474
475
476def get_unique_redefinition_name(name: str, existing: Container[str]) -> str:
477 """Get a simple redefinition name not present among existing.
478
479 For example, for name 'foo' we try 'foo-redefinition', 'foo-redefinition2',
480 'foo-redefinition3', etc. until we find one that is not in existing.
481 """
482 r_name = name + "-redefinition"
483 if r_name not in existing:
484 return r_name
485
486 i = 2
487 while r_name + str(i) in existing:
488 i += 1
489 return r_name + str(i)
490
491
492def check_python_version(program: str) -> None:

Callers 3

save_namedtuple_bodyMethod · 0.90
_prepare_class_namespaceFunction · 0.90
add_attribute_to_classFunction · 0.90

Calls 1

strClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…