-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Speed up mypy startup by avoiding imports #6127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
61a7d82
fc750af
1537e05
d163461
74e48c0
f85b342
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,9 @@ | ||
| """Utility functions with no non-trivial dependencies.""" | ||
| import inspect | ||
| import os | ||
| import pathlib | ||
| import re | ||
| import subprocess | ||
| import sys | ||
| from xml.sax.saxutils import escape | ||
| from typing import TypeVar, List, Tuple, Optional, Dict, Sequence | ||
|
|
||
| MYPY = False | ||
|
|
@@ -143,7 +141,7 @@ def try_find_python2_interpreter() -> Optional[str]: | |
|
|
||
|
|
||
| def write_junit_xml(dt: float, serious: bool, messages: List[str], path: str) -> None: | ||
| """XXX""" | ||
| from xml.sax.saxutils import escape | ||
| if not messages and not serious: | ||
| xml = PASS_TEMPLATE.format(time=dt) | ||
| elif not serious: | ||
|
|
@@ -205,6 +203,7 @@ def correct_relative_import(cur_mod_id: str, | |
|
|
||
|
|
||
| def get_class_descriptors(cls: 'Type[object]') -> Sequence[str]: | ||
| import inspect # Lazy import for minor startup speed win | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What were you timing? I think
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I might have been timing |
||
| # Maintain a cache of type -> attributes defined by descriptors in the class | ||
| # (that is, attributes from __slots__ and C extension classes) | ||
| if cls not in fields_cache: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, I thought I had already made this change.