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

Optional arguments in pyi file are considered positional by mypy #895

Closed
cblegare opened this issue Aug 30, 2021 · 4 comments
Closed

Optional arguments in pyi file are considered positional by mypy #895

cblegare opened this issue Aug 30, 2021 · 4 comments
Labels
bug Something isn't working pep 484 typing related issues

Comments

@cblegare
Copy link

Describe the bug

In the pyi files, some arguments marked as Optional miss a default value, and thus are considered positional (hence required) by mypy.

Expected behavior

Keyword and optional arguments should be annotated as such.

To Reproduce

Write a migration, use the op.drop_table function, run mypy.

Error

migrations/versions/954fd0bb09be_add_users_table.py:26: error: Missing positional argument "schema" in call to "drop_table"
        op.drop_table("users")
        ^

Versions.

  • Python: 3.8
  • Alembic: 1.7.0
  • SQLAlchemy: 1.4.17

Suggestion

Maybe add default values to Optional arguments in pyi files?

Have a nice day!

@cblegare cblegare added the requires triage New issue that requires categorization label Aug 30, 2021
@zzzeek zzzeek added bug Something isn't working pep 484 typing related issues and removed requires triage New issue that requires categorization labels Aug 30, 2021
@sqla-tester
Copy link
Collaborator

Mike Bayer has proposed a fix for this issue in the master branch:

restore default values for keyword arguments in stubs https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/3032

@zzzeek
Copy link
Member

zzzeek commented Aug 30, 2021

if you could click on that review and see that I did it right that would be helpful. cc @CaselIT

@cblegare
Copy link
Author

Haven't run it locally, but this indeed looks good to me :)

@CaselIT
Copy link
Member

CaselIT commented Aug 30, 2021

same for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pep 484 typing related issues
Projects
None yet
Development

No branches or pull requests

4 participants