False `bad-override` on SQLModel `__tablename__ = "..."` ("must both be descriptors")
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
Hướng nghiên cứu
Start by locating Pyrefly's bad-override diagnostic and the logic that compares class member descriptors; the issue does not name source files or tests. Reproduce with the shown SQLModel example using Python 3.13 and SQLModel 0.0.38, then check the existing override tests. Done when a plain string and a declared_attr directive override are accepted without regressing other override checks.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Describe the Bug
Setting __tablename__ to a string on a SQLModel table, which is how SQLModel's docs name a table, is reported as bad-override:
from sqlmodel import Field, SQLModel
class Hero(SQLModel, table=True):
__tablename__ = "heroes"
id: int | None = Field(default=None, primary_key=True)
ERROR Class member `Hero.__tablename__` overrides parent class `SQLModel` in an inconsistent manner [bad-override]
--> repro.py:5:5
`Hero.__tablename__` and `SQLModel.__tablename__` must both be descriptors
SQLModel declares __tablename__ as a @declared_attr classmethod-style descriptor, but SQLAlchemy and SQLModel both accept a plain string in a subclass at runtime. Writing the override as a descriptor does not help either:
from sqlalchemy.orm import declared_attr
class Hero(SQLModel, table=True):
@declared_attr.directive
def __tablename__(cls) -> str:
return "heroes"
This still reports the same error, so there is no spelling that type-checks. In a codebase with many tables, the result is one error per model.
Expected: a plain str (or a declared_attr directive) is accepted as an override of declared_attr __tablename__. Possibly related: #891, #2561.
Versions: pyrefly 1.3.1, sqlmodel 0.0.38, SQLAlchemy 2.0.49, Python 3.13. The config is just python-version = "3.13" (default preset). The basic preset does not report it.
Sandbox Link
No response (needs sqlmodel installed)
(Only applicable for extension issues) IDE Information
No response
- Ngôn ngữ chính
- Rust
- Star
- 7.2k
- Fork
- 578
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của facebook/pyrefly
-
pytorch tensor-shapes typechecking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
good first issue typechecking
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
cargo b warning: unused dependency `zstd`Có thể đã có người làm @Narendersingh007 đã nhận 4 ngày trước. Đang mởgood first issue
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
-
pydantic
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
Tất cả issue của facebook/pyrefly
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
eventflux-io/eventflux#203 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug ui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
userFRM/egui-charts#4068 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
fuzz-crash review-followup
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
marketing
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
aws/aws-emulator#610 ·