-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix psycopg2 #10630
Fix psycopg2 #10630
Conversation
This comment has been minimized.
This comment has been minimized.
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.
Thanks and I'm sorry for the late review. Looks good to me, a few nits below.
Running stubtest for psycopg2 locally fails on my machine because it tries to build it from source and apparently it is missing some dependencies. psycopg2 is special because the compiled wheels exist on PyPI as the diff --git a/tests/stubtest_third_party.py b/tests/stubtest_third_party.py
index af393c35f..65241e7be 100755
--- a/tests/stubtest_third_party.py
+++ b/tests/stubtest_third_party.py
@@ -45,7 +45,10 @@ def run_stubtest(
print_error("fail")
raise
dist_extras = ", ".join(stubtest_settings.extras)
- dist_req = f"{dist_name}[{dist_extras}]=={metadata.version}"
+ pypi_dist_name = dist_name
+ if dist_name == "psycopg2":
+ pypi_dist_name = "psycopg2-binary" # psycopg2 is named psycopg2-binary on PyPI
+ dist_req = f"{pypi_dist_name}[{dist_extras}]=={metadata.version}"
# If tool.stubtest.stubtest_requirements exists, run "pip install" on it.
if stubtest_settings.stubtest_requirements: I don't know how many packages you have that are in the same situation but installing from wheels would make CI faster and cause less problems while developing. It might not be worth the effort though, I don't know. |
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
def format(self, *args, **kwargs) -> Composed: ... | ||
def join(self, seq) -> Composed: ... | ||
def format(self, *args: Composable, **kwargs: Composable) -> Composed: ... | ||
def join(self, seq: SupportsIter[Composable]) -> Composed: ... |
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.
This needs to be Iterable[Composable]
, not SupportsIter[Composable]
. The difference is that
seq: Iterable[Composable]
meansiter(seq): Iterator[Composable]
(hencenext(iter(seq)): Composable
), whileseq: SupportsIter[Composable]
meansiter(seq): Composable
, which is not an iterator.
An implementor of _Composable is required to support + with its own type, not with an arbitrary other implementor of _Composable. This is now required for compatibility with python/typeshed#10630. Signed-off-by: Anders Kaseorg <[email protected]>
…#1714) An implementor of _Composable is required to support + with its own type, not with an arbitrary other implementor of _Composable. This is now required for compatibility with python/typeshed#10630. Signed-off-by: Anders Kaseorg <[email protected]>
This is an error I introduced in python#10630 because I didn't know protocols need to be explicitly inherited from in other protocol subclasses. The added test shows the change. Basically these protocols were unusable.
This is an error I introduced in #10630 because I didn't know protocols need to be explicitly inherited from in other protocol subclasses. The added test shows the change. Basically these protocols were unusable.
Unblocks sbdchd/django-types#74
I did some careful reading of the docs and the C code and some testing in the repl. This hopefully yields a much better quality stubs for psycopg2.