@@ -24,15 +24,15 @@ def __init__(self, importer: Importer, *args, **kwargs):
24
24
# is imported, then the offending library removes its dispatch entries,
25
25
# leaving PackagePickler with a stale dispatch table that may cause
26
26
# unwanted behavior.
27
- self .dispatch = _Pickler .dispatch .copy ()
28
- self .dispatch [FunctionType ] = PackagePickler .save_global
27
+ self .dispatch = _Pickler .dispatch .copy () # type: ignore[misc]
28
+ self .dispatch [FunctionType ] = PackagePickler .save_global # type: ignore[assignment]
29
29
30
30
def save_global (self , obj , name = None ):
31
31
# unfortunately the pickler code is factored in a way that
32
32
# forces us to copy/paste this function. The only change is marked
33
33
# CHANGED below.
34
- write = self .write
35
- memo = self .memo
34
+ write = self .write # type: ignore[attr-defined]
35
+ memo = self .memo # type: ignore[attr-defined]
36
36
37
37
# CHANGED: import module from module environment instead of __import__
38
38
try :
@@ -44,7 +44,7 @@ def save_global(self, obj, name=None):
44
44
_ , parent = _getattribute (module , name )
45
45
# END CHANGED
46
46
47
- if self .proto >= 2 :
47
+ if self .proto >= 2 : # type: ignore[attr-defined]
48
48
code = _extension_registry .get ((module_name , name ))
49
49
if code :
50
50
assert code > 0
@@ -59,13 +59,13 @@ def save_global(self, obj, name=None):
59
59
if parent is module :
60
60
name = lastname
61
61
# Non-ASCII identifiers are supported only with protocols >= 3.
62
- if self .proto >= 4 :
63
- self .save (module_name )
64
- self .save (name )
62
+ if self .proto >= 4 : # type: ignore[attr-defined]
63
+ self .save (module_name ) # type: ignore[attr-defined]
64
+ self .save (name ) # type: ignore[attr-defined]
65
65
write (STACK_GLOBAL )
66
66
elif parent is not module :
67
- self .save_reduce (getattr , (parent , lastname ))
68
- elif self .proto >= 3 :
67
+ self .save_reduce (getattr , (parent , lastname )) # type: ignore[attr-defined]
68
+ elif self .proto >= 3 : # type: ignore[attr-defined]
69
69
write (
70
70
GLOBAL
71
71
+ bytes (module_name , "utf-8" )
@@ -74,7 +74,7 @@ def save_global(self, obj, name=None):
74
74
+ b"\n "
75
75
)
76
76
else :
77
- if self .fix_imports :
77
+ if self .fix_imports : # type: ignore[attr-defined]
78
78
r_name_mapping = _compat_pickle .REVERSE_NAME_MAPPING
79
79
r_import_mapping = _compat_pickle .REVERSE_IMPORT_MAPPING
80
80
if (module_name , name ) in r_name_mapping :
@@ -92,10 +92,10 @@ def save_global(self, obj, name=None):
92
92
except UnicodeEncodeError :
93
93
raise PicklingError (
94
94
"can't pickle global identifier '%s.%s' using "
95
- "pickle protocol %i" % (module , name , self .proto )
95
+ "pickle protocol %i" % (module , name , self .proto ) # type: ignore[attr-defined]
96
96
) from None
97
97
98
- self .memoize (obj )
98
+ self .memoize (obj ) # type: ignore[attr-defined]
99
99
100
100
101
101
def create_pickler (data_buf , importer , protocol = 4 ):
0 commit comments