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

TYP: Add annotations for the py3.12 buffer protocol #24705

Merged
merged 3 commits into from
Sep 14, 2023
Merged

Conversation

BvB93
Copy link
Member

@BvB93 BvB93 commented Sep 14, 2023

With the implementation of PEP 688 the buffer protocol is, as of Python 3.12, now accessible in Python. This PR updates the np.ndarray and np.generic annotations, adding the corresponding __buffer__ method to the both of them in addition to the definition of npt.ArrayLike.

Marking as 1.26 backport as this is a reasonably py3.12 typing feature.

@BvB93 BvB93 added 09 - Backport-Candidate PRs tagged should be backported Static typing labels Sep 14, 2023
@charris
Copy link
Member

charris commented Sep 14, 2023

@BvB93 I have an unrelated question.

charris@fc [numpy.git (prepare-1.26.0-release)]$ git diff main numpy/f2py
diff --git a/numpy/f2py/__init__.pyi b/numpy/f2py/__init__.pyi
index 81b6a24f39..6e3a82cf8f 100644
--- a/numpy/f2py/__init__.pyi
+++ b/numpy/f2py/__init__.pyi
@@ -14,6 +14,7 @@ class _F2PyDict(_F2PyDictBase, total=False):
     ltx: list[str]
 
 __all__: list[str]
+__path__: list[str]
 test: PytestTester

I assume the difference is harmless. Is it?

@BvB93
Copy link
Member Author

BvB93 commented Sep 14, 2023

I assume the difference is harmless. Is it?

Correct, it's harmless. I would recommend leaving __path__ out if it's not too much work (it's an attribute that's explicitly handled by type checkers these days), but either way is fine tbh.

@charris
Copy link
Member

charris commented Sep 14, 2023

The test failures look unrelated. The macos_arm64_test crash is new. Hmm ... Will rerun.

@charris charris merged commit f6bf183 into numpy:main Sep 14, 2023
49 of 50 checks passed
@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Sep 14, 2023
@charris
Copy link
Member

charris commented Sep 14, 2023

Thanks Bas.

@seiko2plus Any chance the aarch64 fixes could have accounted for the macos_arm64_test crash? I'm sorry that I reran the test, but wanted to see if it was repeatable.

@BvB93 BvB93 deleted the buffer branch September 14, 2023 16:33
@seiko2plus
Copy link
Member

Any chance the aarch64 fixes could have accounted for the macos_arm64_test crash?

I ran tests on clang 14 & 15, both were fine. If the partial load refactor (gh-24461) is the issue, then it should be consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants