| 43 | |
| 44 | |
| 45 | class TypeShallowCopier(TypeVisitor[ProperType]): |
| 46 | def visit_unbound_type(self, t: UnboundType) -> ProperType: |
| 47 | return t |
| 48 | |
| 49 | def visit_any(self, t: AnyType) -> ProperType: |
| 50 | return self.copy_common(t, AnyType(t.type_of_any, t.source_any, t.missing_import_name)) |
| 51 | |
| 52 | def visit_none_type(self, t: NoneType) -> ProperType: |
| 53 | return self.copy_common(t, NoneType()) |
| 54 | |
| 55 | def visit_uninhabited_type(self, t: UninhabitedType) -> ProperType: |
| 56 | dup = UninhabitedType() |
| 57 | dup.ambiguous = t.ambiguous |
| 58 | return self.copy_common(t, dup) |
| 59 | |
| 60 | def visit_erased_type(self, t: ErasedType) -> ProperType: |
| 61 | return self.copy_common(t, ErasedType()) |
| 62 | |
| 63 | def visit_deleted_type(self, t: DeletedType) -> ProperType: |
| 64 | return self.copy_common(t, DeletedType(t.source)) |
| 65 | |
| 66 | def visit_instance(self, t: Instance) -> ProperType: |
| 67 | dup = Instance(t.type, t.args, last_known_value=t.last_known_value) |
| 68 | return self.copy_common(t, dup) |
| 69 | |
| 70 | def visit_type_var(self, t: TypeVarType) -> ProperType: |
| 71 | return self.copy_common(t, t.copy_modified()) |
| 72 | |
| 73 | def visit_param_spec(self, t: ParamSpecType) -> ProperType: |
| 74 | dup = ParamSpecType( |
| 75 | t.name, t.fullname, t.id, t.flavor, t.upper_bound, t.default, prefix=t.prefix |
| 76 | ) |
| 77 | return self.copy_common(t, dup) |
| 78 | |
| 79 | def visit_parameters(self, t: Parameters) -> ProperType: |
| 80 | dup = Parameters( |
| 81 | t.arg_types, |
| 82 | t.arg_kinds, |
| 83 | t.arg_names, |
| 84 | variables=t.variables, |
| 85 | is_ellipsis_args=t.is_ellipsis_args, |
| 86 | ) |
| 87 | return self.copy_common(t, dup) |
| 88 | |
| 89 | def visit_type_var_tuple(self, t: TypeVarTupleType) -> ProperType: |
| 90 | dup = TypeVarTupleType( |
| 91 | t.name, t.fullname, t.id, t.upper_bound, t.tuple_fallback, t.default |
| 92 | ) |
| 93 | return self.copy_common(t, dup) |
| 94 | |
| 95 | def visit_unpack_type(self, t: UnpackType) -> ProperType: |
| 96 | dup = UnpackType(t.type) |
| 97 | return self.copy_common(t, dup) |
| 98 | |
| 99 | def visit_partial_type(self, t: PartialType) -> ProperType: |
| 100 | return self.copy_common(t, PartialType(t.type, t.var, t.value_type)) |
| 101 | |
| 102 | def visit_callable_type(self, t: CallableType) -> ProperType: |
no outgoing calls
no test coverage detected
searching dependent graphs…