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

Mypy complains about config attribute #900

Closed
donkirkby opened this issue Sep 6, 2021 · 2 comments
Closed

Mypy complains about config attribute #900

donkirkby opened this issue Sep 6, 2021 · 2 comments
Labels
bug Something isn't working pep 484

Comments

@donkirkby
Copy link

Describe the bug
Mypy generates this error on the env.py script:

Module has no attribute "config"; maybe "configure"?

Expected behavior
No error message on env.py script generated by the alembic init command.

To Reproduce

$ alembic init alembic
  Creating directory /project/alembic ...  done
  Creating directory /project/alembic/versions ...  done
  Generating /project/alembic.ini ...  done
  Generating /project/alembic/env.py ...  done
  Generating /project/alembic/script.py.mako ...  done
  Generating /project/alembic/README ...  done
  Please edit configuration/connection/logging settings in '/project/alembic.ini' before proceeding.
$ mypy .
alembic/env.py:10: error: Module has no attribute "config"; maybe "configure"?
Found 1 error in 1 file (checked 1 source file)
$ 

Error

alembic/env.py:10: error: Module has no attribute "config"; maybe "configure"?

Versions.

  • OS: Ubuntu 20.04
  • Python: 3.8.10
  • Alembic: 1.7.0 (also 1.7.1)
  • SQLAlchemy: 1.4.23
  • Database: None
  • DBAPI: ?
  • mypy: 0.910

Additional context
I worked around the problem by telling mypy not to check the config attribute on line 10 of env.py.

config = context.config  # type: ignore

It's just a guess, but I wondered if this type hint is confusing Mypy.

config: "Config" = None  # type:ignore[assignment]

Have a nice day!
Thanks for sharing the project, and thanks for adding type hints.

@donkirkby donkirkby added the requires triage New issue that requires categorization label Sep 6, 2021
@CaselIT CaselIT added autogenerate for enums a long term subject, tagging issues related to this bug Something isn't working missing behavior not quite a feature and not quite a bug, somehting we need to support and removed requires triage New issue that requires categorization labels Sep 6, 2021
@CaselIT
Copy link
Member

CaselIT commented Sep 6, 2021

That's for the report.

I think the issue is in the generated pyi file. IIRC it's filtered out

@CaselIT CaselIT added pep 484 and removed missing behavior not quite a feature and not quite a bug, somehting we need to support autogenerate for enums a long term subject, tagging issues related to this labels Sep 6, 2021
@sqla-tester
Copy link
Collaborator

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

Added missing attributes from context stubs. https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/3066

rohanpm added a commit to rohanpm/exodus-gw that referenced this issue Sep 8, 2021
This reverts commit 656e2c7.

That automated dependency update was wrongly merged even though it
failed CI, because we had missed branch protection rules in the repo.
We should not update alembic currently due to
sqlalchemy/alembic#900.
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
Projects
None yet
Development

No branches or pull requests

3 participants