microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 769 forks source link

Error creating (partial) type stub for `defusedxml` #2013

Closed Molkree closed 2 years ago

Molkree commented 2 years ago

Environment data

Expected behaviour

Type stub created successfully, probably only for imported interfaces but the whole module would be fine as well.

Actual behaviour

An error occurred when creating type stub for 'defusedxml.ElementTree': Import 'defusedxml.ElementTree' could not be resolved

Logs

[Info  - 12:13:19 am] No configuration file found.
[Info  - 12:13:19 am] No pyproject.toml file found.
[Info  - 12:13:19 am] Setting pythonPath for service "cloned service": "c:\Users\mrmol\Downloads\LeetCode\.venv\Scripts\python.exe"
[Warn  - 12:13:19 am] stubPath c:\Users\mrmol\Downloads\LeetCode\typings is not a valid directory.
[Info  - 12:13:19 am] Assuming Python version 3.10
[Info  - 12:13:19 am] Assuming Python platform Windows
Search paths for c:\Users\mrmol\Downloads\LeetCode
  c:\Users\mrmol\.vscode\extensions\ms-python.vscode-pylance-2021.10.3\dist\typeshed-fallback\stdlib
  c:\Users\mrmol\Downloads\LeetCode
  c:\Users\mrmol\Downloads\LeetCode\typings
  c:\Users\mrmol\.vscode\extensions\ms-python.vscode-pylance-2021.10.3\dist\typeshed-fallback\stubs\...
  c:\Users\mrmol\.vscode\extensions\ms-python.vscode-pylance-2021.10.3\dist\bundled\stubs
  c:\Users\mrmol\AppData\Local\Programs\Python\Python310\DLLs
  c:\Users\mrmol\AppData\Local\Programs\Python\Python310\Lib
  c:\Users\mrmol\AppData\Local\Programs\Python\Python310
  c:\Users\mrmol\Downloads\LeetCode\.venv
  c:\Users\mrmol\Downloads\LeetCode\.venv\Lib\site-packages
[Error - 12:13:20 am] Import 'defusedxml.ElementTree' could not be resolved
[Error - 12:13:20 am] An error occurred when creating type stub for 'defusedxml.ElementTree': Import 'defusedxml.ElementTree' could not be resolved
[Info  - 12:13:20 am] Background analysis(3) root directory: c:\Users\mrmol\.vscode\extensions\ms-python.vscode-pylance-2021.10.3\dist
[Info  - 12:13:20 am] Background analysis(3) started
Background analysis message: setFileOpened
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange
Background analysis message: setConfigOptions
Background analysis message: setImportResolver
Background analysis message: ensurePartialStubPackages
Background analysis message: setAllowedThirdPartyImports
Background analysis message: setTrackedFiles

Code Snippet / Additional information

This is a 3rd party package recommended by python.org.

import defusedxml.ElementTree as ET

I don't quite get why this import can't be resolved when generating type stub because it works fine in code, I get completions on ET. 🤔

Stub generation works fine if I import the whole module:

import defusedxml
erictraut commented 2 years ago

This will be fixed in the next release.

heejaechang commented 2 years ago

fixed in 2021.11.0