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

Mypy error when running nox on Windows #11560

Closed
nitneuqr opened this issue Sep 7, 2024 · 4 comments
Closed

Mypy error when running nox on Windows #11560

nitneuqr opened this issue Sep 7, 2024 · 4 comments

Comments

@nitneuqr
Copy link
Contributor

nitneuqr commented Sep 7, 2024

I don't know if we're supposed to do so, but I'm trying to run the nox -e local command on Windows.

When creating a venv, installing uv on it then running the command, I'm getting the following error:

nox > mypy src/cryptography/ vectors/cryptography_vectors/ tests/ release.py noxfile.py
tests\hazmat\primitives\test_ciphers.py:258: error: Unexpected keyword argument "prot" for "mmap"  [call-arg]
tests\hazmat\primitives\test_ciphers.py:258: error: Module has no attribute "PROT_READ"  [attr-defined]
.nox\local\Lib\site-packages\mypy\typeshed\stdlib\mmap.pyi:35: note: "mmap" defined here
tests\hazmat\primitives\test_aead.py:41: error: Unexpected keyword argument "prot" for "mmap"  [call-arg]
tests\hazmat\primitives\test_aead.py:41: error: Module has no attribute "PROT_READ"  [attr-defined]
.nox\local\Lib\site-packages\mypy\typeshed\stdlib\mmap.pyi:35: note: "mmap" defined here
Found 4 errors in 2 files (checked 202 source files)
nox > Command mypy src/cryptography/ vectors/cryptography_vectors/ tests/ release.py noxfile.py failed with exit code 1
nox > Session local failed.

The local environment is on python 3.12.5 and mypy 1.12.5.

Right now, I've corrected it by placing a # type: ignore on problematic files, is there any other way to do so?

@alex
Copy link
Member

alex commented Sep 7, 2024 via email

@nitneuqr
Copy link
Contributor Author

nitneuqr commented Sep 8, 2024

I'll check this out and try to provide a fix telling mypy to ignore these kind of warnings for windows :)

@nitneuqr
Copy link
Contributor Author

nitneuqr commented Sep 9, 2024

As per mypy documentation, , the following fix could be something like this:

  if sys.platform == "win32":
      large_data = mmap.mmap(-1, 2**29 + 2**20)
  else:
      large_data = mmap.mmap(-1, 2**29 + 2**20, prot=mmap.PROT_READ)

I'm opening a mini PR on the subject; it might hurt coverage though.

@nitneuqr
Copy link
Contributor Author

With integration of #11570, the issue is fixed. Closing!

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

No branches or pull requests

2 participants