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

Silencing mmap mypy warning on windows #11570

Merged
merged 6 commits into from
Sep 12, 2024

Conversation

nitneuqr
Copy link
Contributor

@nitneuqr nitneuqr commented Sep 9, 2024

As per #11560. Even though the lib doesn't exist on Windows

Just realized coverage does not pass as such; the simplest solution would probably be # type: ignore 😞

even though the lib doesn't exist on this platform
large_data = mmap.mmap(-1, 2**29 + 2**20, prot=mmap.PROT_READ)
# Silencing mypy warning on Windows, even though mmap doesn't exist. See:
# https://mypy.readthedocs.io/en/stable/common_issues.html#version-and-platform-checks
if sys.platform == "win32":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately this will produce coverage issues, since it's never reached.

I wonder if an assert sys.platform in {"linux", "darwin"} would work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen it in the documentation, and tried it, as well as assert sys.platform != "win32", without any success. it seems it only works to silence the whole file 😞

@nitneuqr
Copy link
Contributor Author

nitneuqr commented Sep 9, 2024

Pushed new version, probably the dirtiest we can do without going for # type: ignore (which might be the best option).

@@ -255,7 +255,7 @@ def test_update_into_buffer_too_small_gcm(self, backend):
sys.platform not in {"linux", "darwin"}, reason="mmap required"
)
def test_update_auto_chunking():
large_data = mmap.mmap(-1, 2**29 + 2**20, prot=mmap.PROT_READ)
large_data = large_mmap(length=2**29 + 2**20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the coverage bit, a PR that simply moved to a single utility function for these would be good.

@nitneuqr
Copy link
Contributor Author

Should be good, finally :)

Copy link
Member

@alex alex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dumb, I wish mypy had a better way to handle this, but thanks for chasing it down!

@alex alex merged commit 1c32edc into pyca:main Sep 12, 2024
59 checks passed
@nitneuqr nitneuqr deleted the silence-mmap-mypy-warning branch September 12, 2024 20:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants