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

Function copy_type

mypy/copytype.py:34–42  ·  view source on GitHub ↗

Create a shallow copy of a type. This can be used to mutate the copy with truthiness information. Classes compiled with mypyc don't support copy.copy(), so we need a custom implementation.

(t: ProperType)

Source from the content-addressed store, hash-verified

32
33
34def copy_type(t: ProperType) -> ProperType:
35 """Create a shallow copy of a type.
36
37 This can be used to mutate the copy with truthiness information.
38
39 Classes compiled with mypyc don't support copy.copy(), so we need
40 a custom implementation.
41 """
42 return t.accept(TypeShallowCopier())
43
44
45class TypeShallowCopier(TypeVisitor[ProperType]):

Callers 3

true_onlyFunction · 0.90
false_onlyFunction · 0.90
true_or_falseFunction · 0.90

Calls 2

TypeShallowCopierClass · 0.85
acceptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…