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

hashlib constructors unexpected-argument false positive for usedforsecurity #6017

Closed
OJFord opened this issue Mar 28, 2022 · 6 comments · Fixed by pylint-dev/astroid#1662
Closed
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)
Milestone

Comments

@OJFord
Copy link

OJFord commented Mar 28, 2022

Bug description

Python 3.9 added the usedforsecurity keyword-only argument to all hashlib constructors

Configuration

No response

Command used

pylint

Pylint output

E1123: Unexpected keyword argument 'usedforsecurity' in constructor call (unexpected-keyword-arg)

Expected behavior

No error

Pylint version

pylint 3.0.0-a4

OS / Environment

No response

Additional dependencies

No response

@OJFord OJFord added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Mar 28, 2022
@Pierre-Sassoulas
Copy link
Member

Thank you for opening the issue. Could you try with the latest pylint <3 ? 3.0.0 alpha 4 is based on an old version of pylint like 2.10 with breaking change on top of it.

@OJFord
Copy link
Author

OJFord commented Mar 28, 2022

Thanks for the reply - I think it might actually be that python3.8 was (unexpectedly) picked up, in which case the error is correct. Will close once I've confirmed that.

@LuminairPrime
Copy link

Unexpected keyword argument 'usedforsecurity' in constructor call

from hashlib import blake2b
blake2bhash = blake2b(digest_size=10, usedforsecurity=False)
pylint --version
pylint 2.12.2
astroid 2.9.3
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]

@OJFord
Copy link
Author

OJFord commented Apr 1, 2022

Thanks @LuminairPrime, I see the same. Mypy correctly complains in 3.8 but not in 3.9 or 3.10, pylint complains regardless of version.

I take it pylint doesn't use typeshed then, from which mypy gets the (version-switched) correct signature?

@Pierre-Sassoulas Pierre-Sassoulas added False Positive 🦟 A message is emitted but nothing is wrong with the code and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Apr 1, 2022
@Pierre-Sassoulas
Copy link
Member

pylint uses astroid to create the abstract syntax tree. It's possible there's an issue in astroid not being able to create the proper AST for the python 3.9 code.

@OJFord
Copy link
Author

OJFord commented Jun 25, 2022

Thanks! (Aside: didn't realise you could close cross-repo like that now, nice!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Positive 🦟 A message is emitted but nothing is wrong with the code Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade)
Projects
None yet
4 participants