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

v1.10.4 -> v1.11.0: pyright: "__setitem__" method not defined on type "Mapping[str, str]" #1244

Closed
gitpushdashf opened this issue May 16, 2023 · 4 comments
Labels
bug Something isn't working pep 484 typing related issues

Comments

@gitpushdashf
Copy link

Hi Alembic and all,

There seems to be a type change (for better or for worse) that's being caught by pyright -- possibly others.

We have a migration env.py with a statement like configuration["sqlalchemy.url"] = database that's throwing the error when pyright runs. With v1.10.4, there's no such error. I'm not sure if this is part of autogenerated output, if the code was a bit invalid from the start, or if there's something else going on.

In this case, configuration = config.get_section(config.config_ini_section), config = context.config, and from alembic import context.

Let me know if I can provide anything else to help debug.

Thanks!

@gitpushdashf gitpushdashf added the requires triage New issue that requires categorization label May 16, 2023
@zzzeek
Copy link
Member

zzzeek commented May 16, 2023

I would assume you are asserting that the return is not None since the previous type had it as Optional[Dict[str, str]]

@zzzeek zzzeek added bug Something isn't working pep 484 typing related issues labels May 16, 2023
@CaselIT CaselIT removed the requires triage New issue that requires categorization label May 16, 2023
@gitpushdashf
Copy link
Author

Oh, interesting. I wonder if Dict has __setitem__ but Mapping does not? Would Dict be a better type?

@sqla-tester
Copy link
Collaborator

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

restore Dict[str, str] as potential get_section() type https://gerrit.sqlalchemy.org/c/sqlalchemy/alembic/+/4619

@zzzeek
Copy link
Member

zzzeek commented May 16, 2023

it's supposed to be Dict for this case.

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