Open
Conversation
sobolevn
reviewed
Mar 15, 2026
| settings_dict: dict[str, Any] | ||
| alias: str | ||
| queries_log: Any | ||
| queries_log: deque |
Member
There was a problem hiding this comment.
Can you please specify the type arg?
Author
There was a problem hiding this comment.
I have added the type arguments.
| def get_primary_key_column(self, cursor: CursorWrapper | None, table_name: str) -> str | None: ... | ||
| def get_primary_key_columns(self, cursor: CursorWrapper | None, table_name: str) -> list[str] | None: ... | ||
| def get_constraints(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... | ||
| def get_sequences(self, cursor: CursorWrapper, table_name: str, table_fields: Iterable = ()) -> list[dict]: ... |
| def get_relations(self, cursor: CursorWrapper, table_name: str) -> dict[str, tuple[str, str]]: ... | ||
| def get_primary_key_column(self, cursor: CursorWrapper, table_name: str) -> str | None: ... | ||
| def get_primary_key_columns(self, cursor: CursorWrapper, table_name: str) -> list[str] | None: ... | ||
| def get_constraints(self, cursor: CursorWrapper, table_name: str) -> dict[str, dict]: ... |
b8845f0 to
31b6e7a
Compare
sobolevn
reviewed
Mar 15, 2026
| def table_names(self, cursor: CursorWrapper | None = None, include_views: bool = False) -> list[str]: ... | ||
| def get_table_list(self, cursor: CursorWrapper | None) -> Any: ... | ||
| def get_table_description(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... | ||
| def get_table_list(self, cursor: CursorWrapper) -> list: ... |
Author
There was a problem hiding this comment.
I added type args for this one and the one below.
| def get_constraints(self, cursor: CursorWrapper | None, table_name: str) -> Any: ... | ||
| def get_sequences( | ||
| self, cursor: CursorWrapper, table_name: str, table_fields: Iterable[Field] = () | ||
| ) -> list[dict]: ... |
This comment has been minimized.
This comment has been minimized.
31b6e7a to
0a68003
Compare
Author
This is an issue in the zulip code, both for loops use the same |
Contributor
|
Diff from mypy_primer, showing the effect of this PR on type check results on a corpus of open source code: zulip (https://github.com/zulip/zulip)
+ zerver/lib/migrate.py:120: error: Incompatible types in assignment (expression has type "_SequenceDict", variable has type "_ConstraintDict") [assignment]
+ zerver/lib/migrate.py:121: error: TypedDict "_ConstraintDict" has no key "name" [typeddict-item]
+ zerver/lib/migrate.py:122: error: TypedDict "_ConstraintDict" has no key "column" [typeddict-item]
+ zerver/lib/migrate.py:122: note: Did you mean "columns"?
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A few improvements to the typing in the database backend code:
Anyto better types in some places.| Nonefrom arguments where the method uses the argument without checking whether it is None.