Skip to content

Commit a59efd9

Browse files
committed
Prefer typeshed over stub packages
This avoids picking up the backport of dataclasses when type checking in Python 3.7 mode. It will still be picked up in Python 3.6 mode.
1 parent 014106b commit a59efd9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

mypy/modulefinder.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,13 @@ def _find_module(self, id: str, use_typeshed: bool) -> ModuleSearchResult:
267267
third_party_stubs_dirs.clear()
268268
found_possible_third_party_missing_type_hints = False
269269
python_mypy_path = self.search_paths.mypy_path + self.search_paths.python_path
270-
candidate_base_dirs = (self.find_lib_path_dirs(id, python_mypy_path) +
271-
third_party_stubs_dirs +
272-
third_party_inline_dirs)
270+
candidate_base_dirs = self.find_lib_path_dirs(id, python_mypy_path)
273271
if use_typeshed:
272+
# Search for stdlib stubs in typeshed before installed
273+
# stubs to avoid picking up backports (dataclasses, for
274+
# example) when the library is included in stdlib.
274275
candidate_base_dirs += self.find_lib_path_dirs(id, self.search_paths.typeshed_path)
276+
candidate_base_dirs += third_party_stubs_dirs + third_party_inline_dirs
275277

276278
# If we're looking for a module like 'foo.bar.baz', then candidate_base_dirs now
277279
# contains just the subdirectories 'foo/bar' that actually exist under the

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy