-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Update documentation regarding PEP 681
support with mypy
#9463
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
Conversation
This also fixes a small typo
doc/build/orm/dataclasses.rst
Outdated
.. note:: Support for :pep:`681` in typing tools as of **July 3, 2022** is | ||
limited and is currently known to be supported by Pyright_, but not yet | ||
.. note:: Support for :pep:`681` in typing tools as of **March 6, 2023** is | ||
limited and is currently known to be fully supported by Pyright_ and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would take the word "limited" out , at this point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed.
as of March 9, 2023 is currently known to be fully supported
(btw today it's the 9th :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed.
as of March 9, 2023 is currently known to be fully supported
(btw today it's the 9th :)
I've added 6th as it was the release date of mypy 1.1.1
;), but I could change to today as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
either one is fine. we could also use just the month. It's there just to give a general feel for time when the statement was written/updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can let this poor submitter go free, it's fine
While I'm on this issue I encountered something weird while working with dataclasses: does column definition order matters when defining models? With the following one: class Model(Base):
__tablename__ = "model"
id: Mapped[int] = mapped_column(primary_key=True, init=False)
uuid: Mapped[UUID] = mapped_column(default=None, insert_default=uuid4)
name: Mapped[str] = mapped_column(
String(255), doc="Name of the model", comment="Name of the model"
)
schemas: Mapped[List["Schema"]] = relationship(
back_populates="model",
doc="List of linked schemas",
) I get the following error: Edit: this behavior seems to come from the Python |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of zzzeek to try to get revision 27ecc83 of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change 27ecc83: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4503 |
I think it's implied by the docs, since all that logic is delegated to dataclasses. but I guess we could add a note here so that it gets mentioned #9410 |
Federico Caselli (CaselIT) wrote: depending on what #9467 turns out to be, mypy may not yet correctly support this pep View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4503 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
turns out we are wrong. mypy has included pep-681 but they did not fix all issues with it, including the main issue that SQLAlchemy needs for it to work.
See python/mypy#13856 , #9467 , python/mypy#14868 .
So while this PR was to be celebratory, it instead needs to be a "if using mypy 1.1.1, you will need to install "type ignores" for all constructors, or stay on mypy 1.0.0 in the interim" :( or something else. not really sure
Nice catch, my mistake I only trusted the mypy's changelog, and did not apply mypy yet on a project I'm working on after switching to |
mike bayer (zzzeek) wrote: we need to wait on this until mypy fixes python/mypy#13856 View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4503 |
I guess this could be closed at least unlit mypy fixes its implementation of pep 681 |
It can, as 3a47052 has been added since |
sorry @Viicos , but thanks for making us look to at mypy ultimately finding this issue. hopefully we can redo the changes here soon |
Federico Caselli (CaselIT) wrote: mypy has an issue with pep 681 and it needs to be fixed before merging this change View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4503 |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/4503 has been abandoned. That means that at least for the moment I need to close this pull request. Sorry it didn't work out :( |
See https://mypy-lang.blogspot.com/2023/03/mypy-111-released.html
This also fixes a small typo
Description
Checklist
This pull request is:
must include a complete example of the issue. one line code fixes without an
issue and demonstration will not be accepted.
Fixes: #<issue number>
in the commit messageinclude a complete example of how the feature would look.
Fixes: #<issue number>
in the commit messageHave a nice day!