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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/hazmat/primitives/test_aead.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ def _aead_supported(cls):
return False


def large_mmap():
return mmap.mmap(-1, 2**32, prot=mmap.PROT_READ)
def large_mmap(length: int = 2**32):
# Silencing mypy prot argument warning on Windows, even though this
# function is only used in non-Windows-based tests.
return mmap.mmap(-1, length, prot=mmap.PROT_READ) # type: ignore[call-arg,attr-defined,unused-ignore]


@pytest.mark.skipif(
Expand Down
4 changes: 2 additions & 2 deletions tests/hazmat/primitives/test_ciphers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


import binascii
import mmap
import os
import sys

Expand All @@ -20,6 +19,7 @@
)

from ...utils import load_nist_vectors, load_vectors_from_file
from .test_aead import large_mmap


def test_deprecated_ciphers_import_with_warning():
Expand Down Expand Up @@ -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.


key = b"\x00" * 16
c = ciphers.Cipher(AES(key), modes.ECB())
Expand Down