Skip to content
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

Pyright: Mapped is considered unhashable #262

Closed
mrcljx opened this issue Dec 30, 2023 · 0 comments
Closed

Pyright: Mapped is considered unhashable #262

mrcljx opened this issue Dec 30, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@mrcljx
Copy link
Contributor

mrcljx commented Dec 30, 2023

Describe the bug

I'm getting a Type "Mapped[int]" is not hashable error in Pyright when trying to use a column in a dictionary.

Expected behavior

Pyright should not report an error.

To Reproduce

from sqlalchemy import Column, Integer
from sqlalchemy.orm import Mapped

class MyModel:
    id: Mapped[int] = Column("id", Integer, primary_key=True)

data = {MyModel.id: 1}

Error

/path/to/file.py
  /path/to/file.py:9:9 - error: Dictionary key must be hashable
   Type "Mapped[int]" is not hashable (reportGeneralTypeIssues)

Versions.

  • OS: macOS
  • Python: 3.10
  • SQLAlchemy: 1.4.48
  • mypy: None (Pyright: 1.1.343)
  • SQLAlchemy2-stubs: 0.0.2a37

Additional context

This is caused by the lack of __hash__ in ColumnOperators.

The issue does not appear when using SA because __hash__ has been added there.

@mrcljx mrcljx added the requires triage New issue that requires categorization label Dec 30, 2023
mrcljx added a commit to mrcljx/sqlalchemy2-stubs that referenced this issue Dec 30, 2023
@CaselIT CaselIT added bug Something isn't working and removed requires triage New issue that requires categorization labels Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants