27
27
import time
28
28
import re
29
29
import types
30
- from typing import List , Protocol
30
+ from typing import Any , Dict , List , Protocol
31
31
import zipfile
32
32
import zipimport
33
33
import warnings
94
94
resource_listdir = None
95
95
resource_filename = None
96
96
resource_exists = None
97
- _distribution_finders = None
98
- _namespace_handlers = None
99
- _namespace_packages = None
100
97
101
98
102
99
warnings .warn (
@@ -120,11 +117,10 @@ class PEP440Warning(RuntimeWarning):
120
117
parse_version = packaging .version .Version
121
118
122
119
123
- _state_vars = {}
120
+ _state_vars : Dict [ str , Any ] = {}
124
121
125
122
126
- def _declare_state (vartype , ** kw ):
127
- globals ().update (kw )
123
+ def _declare_state (vartype : str , ** kw : object ) -> None :
128
124
_state_vars .update (dict .fromkeys (kw , vartype ))
129
125
130
126
@@ -2025,7 +2021,8 @@ def __init__(self, importer):
2025
2021
self ._setup_prefix ()
2026
2022
2027
2023
2028
- _declare_state ('dict' , _distribution_finders = {})
2024
+ _distribution_finders = {}
2025
+ _declare_state ('dict' , _distribution_finders = _distribution_finders )
2029
2026
2030
2027
2031
2028
def register_finder (importer_type , distribution_finder ):
@@ -2198,8 +2195,10 @@ def resolve_egg_link(path):
2198
2195
2199
2196
register_finder (importlib .machinery .FileFinder , find_on_path )
2200
2197
2201
- _declare_state ('dict' , _namespace_handlers = {})
2202
- _declare_state ('dict' , _namespace_packages = {})
2198
+ _namespace_handlers = {}
2199
+ _declare_state ('dict' , _namespace_handlers = _namespace_handlers )
2200
+ _namespace_packages = {}
2201
+ _declare_state ('dict' , _namespace_packages = _namespace_packages )
2203
2202
2204
2203
2205
2204
def register_namespace_handler (importer_type , namespace_handler ):
0 commit comments