returns icon indicating copy to clipboard operation
returns copied to clipboard

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

Open wizard-28 opened this issue 1 year ago • 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 <[email protected]>"]
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

wizard-28 avatar Mar 05 '23 19:03 wizard-28

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

sobolevn avatar Mar 07 '23 06:03 sobolevn

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 <[email protected]>"]
   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

wizard-28 avatar Mar 09 '23 13:03 wizard-28

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

sobolevn avatar Mar 09 '23 20:03 sobolevn

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)
λ

wizard-28 avatar Mar 09 '23 20:03 wizard-28

Sorry, I cannot reproduce it :(

sobolevn avatar Mar 09 '23 22:03 sobolevn

Can you please create a docker image with this problem?

sobolevn avatar Mar 09 '23 22:03 sobolevn

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

aivanoved avatar Aug 10 '23 19:08 aivanoved