dry-python/returns

error: Error importing plugin "returns.contrib.mypy.returns_plugin": No module named 'returns' [misc]

wizard-28 opened this issue ยท 7 comments

Bug report

What's wrong

Mypy is unable to use the plugin. It errors out with the following message:

error: Error importing plugin "returns.contrib.mypy.returns_plugin": No module named 'returns'  [misc]

Here's my pyproject.toml:

[tool.poetry]
name = "test"
version = "0.1.0"
description = ""
authors = ["Sourajyoti Basak <wiz28@protonmail.com>"]
readme = "README.md"

[tool.poetry.dependencies]
python = "^3.10"
returns = "^0.19.0"
mypy = "^0.950"

[tool.mypy]
plugins = ["returns.contrib.mypy.returns_plugin"]
allow_redefinition = false
check_untyped_defs = true
ignore_errors = false
ignore_missing_imports = true
implicit_reexport = false
local_partial_types = true
no_implicit_optional = true
strict_equality = true
strict_optional = true
warn_no_return = true
warn_redundant_casts = true
warn_unreachable = true
warn_unused_configs = true
warn_unused_ignores = true

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

How is that should be

mypy successfully works.

System information

  • python version: 3.10.6
  • returns version: 0.19.0
  • mypy version: 0.950

Can you try checking import returns with python and mypy without a plugin?

Can you try checking import returns with python and mypy without a plugin?

code/python/test is ๐Ÿ“ฆ v0.1.0 via ๐Ÿ v3.10.6 (test-py3.10) took 4s
ฮป bat pyproject.toml
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
       โ”‚ File: pyproject.toml
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1   โ”‚ [tool.poetry]
   2   โ”‚ name = "test"
   3   โ”‚ version = "0.1.0"
   4   โ”‚ description = ""
   5   โ”‚ authors = ["Sourajyoti Basak <wiz28@protonmail.com>"]
   6   โ”‚ readme = "README.md"
   7   โ”‚
   8   โ”‚ [tool.poetry.dependencies]
   9   โ”‚ python = "^3.10"
  10   โ”‚ returns = "^0.19.0"
  11   โ”‚ mypy = "^0.950"
  12   โ”‚
  13   โ”‚ [tool.mypy]
  14   โ”‚ # plugins = ["returns.contrib.mypy.returns_plugin"]
  15   โ”‚ allow_redefinition = false
  16   โ”‚ check_untyped_defs = true
  17   โ”‚ ignore_errors = false
  18   โ”‚ ignore_missing_imports = true
  19   โ”‚ implicit_reexport = false
  20   โ”‚ local_partial_types = true
  21   โ”‚ no_implicit_optional = true
  22   โ”‚ strict_equality = true
  23   โ”‚ strict_optional = true
  24   โ”‚ warn_no_return = true
  25   โ”‚ warn_redundant_casts = true
  26   โ”‚ warn_unreachable = true
  27   โ”‚ warn_unused_configs = true
  28   โ”‚ warn_unused_ignores = true
  29   โ”‚
  30   โ”‚ [build-system]
  31   โ”‚ requires = ["poetry-core"]
  32   โ”‚ build-backend = "poetry.core.masonry.api"
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

code/python/test is ๐Ÿ“ฆ v0.1.0 via ๐Ÿ v3.10.6 (test-py3.10) took 5s
ฮป bat test/__init__.py
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
       โ”‚ File: test/__init__.py
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
   1   โ”‚ import returns
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€

code/python/test is ๐Ÿ“ฆ v0.1.0 via ๐Ÿ v3.10.6 (test-py3.10)
ฮป mypy test/
Success: no issues found in 1 source file

Can you run test/__init__.py with python? python test/__init__.py

Can you run test/__init__.py with python? python test/__init__.py

code/python/test is ๐Ÿ“ฆ v0.1.0 via ๐Ÿ v3.10.6 (test-py3.10)
ฮป python3 ./test/__init__.py

code/python/test is ๐Ÿ“ฆ v0.1.0 via ๐Ÿ v3.10.6 (test-py3.10)
ฮป

Sorry, I cannot reproduce it :(

Can you please create a docker image with this problem?

I have encountered the same error, will be trying to make a minimum example (it has been difficult to do so, though)

Setup:

python: 3.11.4
returns: 0.19.0
mypy: 1.4.1