microsoft / pylance-release

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

Argument of type "Module("NAME")" cannot be assigned to parameter "PARAM" of type "Module("NAME")" #485

Closed FredHappyface closed 3 years ago

FredHappyface commented 3 years ago

Environment data

Expected behaviour

No type error is detected as the types are equal

Actual behaviour

Argument of type "Module("PySimpleGUI")" cannot be assigned to parameter "pySimpleGui" of type "Module("PySimpleGUI")" in function "__init__"
  Type "Module("PySimpleGUI")" cannot be assigned to type "Module("PySimpleGUI")"

Logs

[Info  - 17:57:14] Pylance language server 2020.10.0 (pyright d1f950ac) starting
[Info  - 17:57:14] Server root directory: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist
[Info  - 17:57:14] No configuration file found.
[Info  - 17:57:14] Setting pythonPath for service "Cli2Gui": "C:\Python39\python.exe"
Search paths found for configured python interpreter:
  C:\Python39\DLLs
  C:\Python39\lib
  C:\Python39
  C:\Users\Dell\AppData\Roaming\Python\Python39\site-packages
  C:\Python39\lib\site-packages
[Error - 17:57:14] stubPath c:\Users\Dell\Documents\GitHub\Cli2Gui\typings is not a valid directory.
[Info  - 17:57:14] Assuming Python version 3.9
[Info  - 17:57:14] Assuming Python platform Windows
[Info  - 17:57:14] Searching for source files
[Info  - 17:57:14] Found 26 source files
[Info  - 17:57:14] Background analysis(1) root directory: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist
[Info  - 17:57:14] Background analysis(1) started
Background analysis message: setConfigOptions
Background analysis message: setTrackedFiles
IntelliCode model c:\Users\Dell\.vscode\extensions\visualstudioexptteam.vscodeintellicode-1.2.10\cache\E61945A9A512ED5E1A3EE3F1A2365B88F8FE_E4E9EADA96734F01970E616FAB2FAC19
Loading ONNX runtime...
Loaded ONNX runtime. Creating IntelliCode session...
2020-10-13 16:57:14.9719427 [I:onnxruntime:, inference_session.cc:174 onnxruntime::InferenceSession::ConstructorCommon] Creating and using per session threadpools since use_per_session_threads_ is true
2020-10-13 16:57:14.9827741 [I:onnxruntime:, inference_session.cc:840 onnxruntime::InferenceSession::Initialize] Initializing session.
2020-10-13 16:57:14.9828608 [I:onnxruntime:, inference_session.cc:865 onnxruntime::InferenceSession::Initialize] Adding default CPU execution provider.
2020-10-13 16:57:14.9897146 [I:onnxruntime:, reshape_fusion.cc:37 onnxruntime::ReshapeFusion::ApplyImpl] Total fused reshape node count: 0
2020-10-13 16:57:14.9927381 [I:onnxruntime:, reshape_fusion.cc:37 onnxruntime::ReshapeFusion::ApplyImpl] Total fused reshape node count: 0
2020-10-13 16:57:15.0028152 [V:onnxruntime:, inference_session.cc:679 onnxruntime::InferenceSession::TransformGraph] Node placements
2020-10-13 16:57:15.0028948 [V:onnxruntime:, inference_session.cc:681 onnxruntime::InferenceSession::TransformGraph] All nodes have been placed on [CPUExecutionProvider].
2020-10-13 16:57:15.0030720 [V:onnxruntime:, session_state.cc:71 onnxruntime::SessionState::CreateGraphInfo] SaveMLValueNameIndexMapping
2020-10-13 16:57:15.0036889 [V:onnxruntime:, session_state.cc:116 onnxruntime::SessionState::CreateGraphInfo] Done saving OrtValue mappings.
2020-10-13 16:57:15.0102932 [I:onnxruntime:, finalize_session_state.cc:173 onnxruntime::SaveInitializedTensors] Saving initialized tensors.
2020-10-13 16:57:15.0230019 [I:onnxruntime:, finalize_session_state.cc:225 onnxruntime::SaveInitializedTensors] Done saving initialized tensors
2020-10-13 16:57:15.0291212 [I:onnxruntime:, inference_session.cc:954 onnxruntime::InferenceSession::Initialize] Session successfully initialized.
Created IntelliCode session.
Background analysis message: markAllFilesDirty
Background analysis message: setFileOpened
Background analysis message: analyze
[BG(1)] analyzing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py ...
[BG(1)]   parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (231ms)
[BG(1)]   parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\builtins.pyi [fs read 5ms] (203ms)
[BG(1)]   binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\builtins.pyi (70ms)
[BG(1)]   binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (9ms)
[BG(1)]   checking: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py ...
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi [fs read 1ms] (23ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\_typeshed\__init__.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi [fs read 1ms] (3ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\typing_extensions.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\typing.pyi [fs read 1ms] (58ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\typing.pyi (14ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\__future__.pyi [fs read 1ms] (2ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\__future__.pyi (0ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\sys.pyi [fs read 0ms] (11ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\sys.pyi (4ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\json\__init__.pyi [fs read 0ms] (9ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\json\__init__.pyi (2ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\__init__.pyi [fs read 1ms] (58ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\__init__.pyi ...
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\dumper.pyi [fs read 1ms] (28ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\dumper.pyi (0ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\error.pyi [fs read 0ms] (0ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\error.pyi (1ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\events.pyi [fs read 0ms] (1ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\events.pyi (1ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\loader.pyi [fs read 0ms] (42ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\loader.pyi (2ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\nodes.pyi [fs read 0ms] (1ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\nodes.pyi (0ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\tokens.pyi [fs read 1ms] (3ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\tokens.pyi (2ms)
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\cyaml.pyi [fs read 0ms] (1ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\cyaml.pyi (1ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\third_party\2and3\yaml\__init__.pyi (87ms)
[BG(1)]     parsing: C:\Python39\lib\site-packages\getostheme\__init__.py [fs read 0ms] (42ms)
[BG(1)]     binding: C:\Python39\lib\site-packages\getostheme\__init__.py (2ms)
[BG(1)]     parsing: C:\Python39\lib\site-packages\pypandoc\__init__.py [fs read 1ms] (37ms)
[BG(1)]     binding: C:\Python39\lib\site-packages\pypandoc\__init__.py (6ms)
[BG(1)]     parsing: C:\Python39\lib\site-packages\PySimpleGUI\__init__.py [fs read 0ms] (3ms)
[BG(1)]     binding: C:\Python39\lib\site-packages\PySimpleGUI\__init__.py ...
[BG(1)]       parsing: C:\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py [fs read 7ms] (505ms)
[BG(1)]       binding: C:\Python39\lib\site-packages\PySimpleGUI\PySimpleGUI.py (147ms)
[BG(1)]     binding: C:\Python39\lib\site-packages\PySimpleGUI\__init__.py (653ms)
[BG(1)]     parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\__init__.py [fs read 1ms] (2ms)
[BG(1)]     binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\__init__.py ...
[BG(1)]       parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\decorators.py [fs read 0ms] (31ms)
[BG(1)]       binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\decorators.py (2ms)
[BG(1)]     binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\__init__.py (33ms)
[BG(1)]     parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\c2gtypes.py [fs read 0ms] (1ms)
[BG(1)]     binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\c2gtypes.py (1ms)
[BG(1)]     parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\pysimplegui2args.py [fs read 1ms] (8ms)
[BG(1)]     binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\pysimplegui2args.py (5ms)
[BG(1)]     parsing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\widgets.py [fs read 0ms] (14ms)
[BG(1)]     binding: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\widgets.py (2ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\abc.pyi [fs read 0ms] (0ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\abc.pyi (0ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\os\__init__.pyi [fs read 1ms] (14ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\os\__init__.pyi (4ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\io.pyi [fs read 0ms] (8ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\io.pyi (5ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\types.pyi [fs read 0ms] (9ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\types.pyi (3ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\queue.pyi [fs read 0ms] (1ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\queue.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\__init__.pyi [fs read 0ms] (38ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\__init__.pyi ...
[BG(1)]       parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\constants.pyi [fs read 0ms] (1ms)
[BG(1)]       binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\constants.pyi (1ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\__init__.pyi (32ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\random.pyi [fs read 0ms] (4ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\random.pyi (2ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\json\decoder.pyi [fs read 0ms] (0ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\json\decoder.pyi (1ms)
[BG(1)]     parsing: C:\Python39\lib\site-packages\pypandoc\py3compat.py [fs read 0ms] (12ms)
[BG(1)]     binding: C:\Python39\lib\site-packages\pypandoc\py3compat.py (0ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\subprocess.pyi [fs read 1ms] (7ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\subprocess.pyi (6ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\re.pyi [fs read 1ms] (2ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\re.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\enum.pyi [fs read 0ms] (1ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\enum.pyi (2ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\os\path.pyi [fs read 0ms] (7ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\os\path.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tempfile.pyi [fs read 0ms] (3ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tempfile.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\locale.pyi [fs read 1ms] (13ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\locale.pyi (0ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\warnings.pyi [fs read 0ms] (3ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\warnings.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\calendar.pyi [fs read 0ms] (3ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\calendar.pyi (2ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\datetime.pyi [fs read 1ms] (6ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\2and3\datetime.pyi (4ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\itertools.pyi [fs read 0ms] (2ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\itertools.pyi (4ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\inspect.pyi [fs read 0ms] (5ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\inspect.pyi (4ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\_tkinter.pyi [fs read 1ms] (1ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\_tkinter.pyi (1ms)
[BG(1)]     parsing: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\font.pyi [fs read 0ms] (2ms)
[BG(1)]     binding: c:\Users\Dell\.vscode\extensions\ms-python.vscode-pylance-2020.10.0\dist\typeshed-fallback\stdlib\3\tkinter\font.pyi (2ms)
[BG(1)]   checking: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (2029ms)
[Info  - 17:57:17] [BG(1)] Long operation: checking: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (2029ms)
[BG(1)] analyzing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (2547ms)
[Info  - 17:57:17] [BG(1)] Long operation: analyzing: c:\Users\Dell\Documents\GitHub\Cli2Gui\cli2gui\application\application.py (2547ms)
Background analysis message: resumeAnalysis
Background analysis message: getDiagnosticsForRange
Background analysis message: getDiagnosticsForRange

Code Snippet / Additional information

import PySimpleGUI as pySimpleGuiType
import PySimpleGUI as pySimpleGui

class Widgets():
    """Widgets class holding methods to create widgets in addition to a sizes
    attribute that can be overridden to provide the end user with customisation
    over the size of the gui
    """
    def __init__(self, sizes: dict[str, Any], pySimpleGui: pySimpleGuiType):
                ...

Widgets(widgetSizes, pySimpleGui) # type error is triggered here 
erictraut commented 3 years ago

Can you explain what you're trying to do here? Is your intent to pass a module to the init routine of Widgets? Or are you supposed to pass a class within that module? If the method accepts any module, you should probably annotate it with object because a module in itself isn't really a type in the Python type system. Arguably, Pylance should flag it as an error if you try to use a module within a type annotation.

FredHappyface commented 3 years ago

Yeah, the module is passed to init

This is so the user gets to select which pysimplegui module they want to use and these (essentially) have the same signatures so I wanted to pass through a type where pylance would not flag every method and class that is a member of the pysimplegui module (which using object would do)

Not sure what the best workaround would be in my case. But it is intended that the module is passed to the class (this then has functions that spit out various widgets)

erictraut commented 3 years ago

This is an unusual (and I would claim a bad) interface. Classes should be used in cases like this, not modules.

From a type checking perspective, there aren't any great options here. Modules don't have "signatures", and one module cannot be assigned to another. The best workaround I can think of is to annotate it with object or Any. Annotating it with a module won't work.

FredHappyface commented 3 years ago

It probably wasn't the best design decision to be honest though I'm pretty sure that's the only way I can interact with that particular module. Using Any probably is the best call in my case.

Thank you for your time on this :)