Skip to content

IndexError: list index out of range #16674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joshvoigts opened this issue Dec 18, 2023 · 7 comments
Closed

IndexError: list index out of range #16674

joshvoigts opened this issue Dec 18, 2023 · 7 comments
Labels

Comments

@joshvoigts
Copy link

Crash Report

Mypy crashes when run on a python repo with mypy .

Traceback

error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.7.1
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5727, in accept
  File "mypy/nodes.py", line 2211, in accept
  File "mypy/checkexpr.py", line 5202, in visit_lambda_expr
  File "mypy/nodes.py", line 2204, in expr
IndexError: list index out of range

To Reproduce

Run mypy . on our private repo. It seems to fail on a particular python file giving -1 as the line number.

Your Environment

  • Mypy version used: 1.4.1 and 1.7.1 both seem to crash.
  • Mypy command-line flags: n/a
  • Mypy configuration options from mypy.ini (and other config files):
[tool.mypy]
disallow_incomplete_defs = true

no_incremental = true

plugins = "sqlalchemy.ext.mypy.plugin"

warn_redundant_casts = true
warn_unreachable = true
warn_unused_ignores = true

[[tool.mypy.overrides]]
module = "flask_sqlalchemy"
ignore_missing_imports = true
  • Python version used: 3.9.11
  • Operating system and version: macos 14.2
@hauntsaninja
Copy link
Collaborator

Any chance you can make a shareable repro? E.g. try removing stuff from the file until you get something small enough to redact that mypy still crashes on. Also worth checking if the crash reproduces without the sqlalchemy plugin.

@joshvoigts
Copy link
Author

I spent a couple hours trying to reproduce this but was struggling. I think it does have something to do with the sqlalchemy plugin. If I remove @declared_mixin from any of the classes I'm mixing in it no longer seems to error. If I include the library that has the mixin in it directly in the project it also no longer seems to error which makes it tough to create a minimal example. I don't think I can spend too much more time on this, so feel free to close if it's not actionable.

@hauntsaninja
Copy link
Collaborator

What if you keep @declared_mixin, but remove plugins = "sqlalchemy.ext.mypy.plugin" from your mypy configuration?

@tyre
Copy link

tyre commented Jan 31, 2024

Adding another config example, as we're running into this too while trying to upgrade to 3.11. We're trying 1.8 and also 1.7 to see if it works, but no dice.

/Users/me/Library/Caches/pypoetry/virtualenvs/backend-ZZ6YV39x-py3.11/lib/python3.11/site-packages/fastapi_users_db_sqlalchemy/__init__.py:-1: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.8.0
Traceback (most recent call last):
  File "mypy/checkexpr.py", line 5727, in accept
  File "mypy/nodes.py", line 2213, in accept
  File "mypy/checkexpr.py", line 5202, in visit_lambda_expr
  File "mypy/nodes.py", line 2206, in expr
IndexError: list index out of range
[mypy]
# We cannot use the pydantic.mypy plugin yet as it is not compatible with mypy 0.910
plugins = loguru_mypy, sqlalchemy.ext.mypy.plugin
exclude = alembic/versions/
follow_imports = normal
check_untyped_defs = True
disallow_incomplete_defs = True
disallow_untyped_defs = True
namespace_packages = True
warn_unused_ignores = True
show_error_codes = True
local_partial_types = True

@hauntsaninja
Copy link
Collaborator

It seems like this might be specific to sqlalchemy.ext.mypy.plugin, in which case you might be better off reporting to that project. They're probably also going to ask for a repro though

@Hnasar
Copy link
Contributor

Hnasar commented Feb 5, 2024

this might be already filed with sqlalchemy here sqlalchemy/sqlalchemy#10282

@sterliakov
Copy link
Collaborator

(yes, that one is newer but comes with a reproducer!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants