Skip to content

Commit eb9d878

Browse files
committed
Use a module-level lazy import for urllib.parse
Replace the in-function import with a top-level lazy import, keeping urllib.parse off the module import path while declaring it with the other imports.
1 parent 2ac8c38 commit eb9d878

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

Lib/mimetypes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
except ImportError:
3434
_winreg = None
3535

36+
lazy import urllib.parse
37+
3638
__all__ = [
3739
"knownfiles", "inited", "MimeTypes",
3840
"guess_type", "guess_file_type", "guess_all_extensions", "guess_extension",
@@ -131,7 +133,6 @@ def guess_type(self, url, strict=True):
131133
if isinstance(url, str) and ':' not in url:
132134
return self.guess_file_type(url, strict=strict)
133135

134-
import urllib.parse
135136
p = urllib.parse.urlparse(url)
136137
if p.scheme and len(p.scheme) > 1:
137138
scheme = p.scheme

0 commit comments

Comments
 (0)