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

Pylint doesn't know that hashlib's SHAKE hashers take a positional argument in their hexdigest #4039

Closed
timmc-edx opened this issue Jan 22, 2021 · 3 comments
Labels
Bug 🪲 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

@timmc-edx
Copy link

Steps to reproduce

Run pylint on this file:

import hashlib

hasher = hashlib.shake_128("test".encode())
output = hasher.hexdigest(16)
print(output)

Current behavior

Emits linter error regarding hexdigest:

lint.py:4:9: E1121: Too many positional arguments for method call (too-many-function-args)

Expected behavior

No linter error for that line. Unlike the other hash functions, SHAKE-128 (and SHAKE-256) have variable length output, so their hexdigest methods take a positional argument specifying the desired number of output bytes.

pylint --version output

$ pylint --version
pylint 2.6.0
astroid 2.4.2
Python 3.8.5 (default, Jul 28 2020, 12:59:40) 
[GCC 9.3.0]
@hippo91
Copy link
Contributor

hippo91 commented Jan 30, 2021

@timmc-edx thanks for the report. I can reproduce it. Seems like the astroid's brain for hashlib doesn't take into account
SHAKE variable length digest.

@hippo91 hippo91 added Needs astroid Brain 🧠 Needs a brain tip in astroid (then an astroid upgrade) Bug 🪲 False Positive 🦟 A message is emitted but nothing is wrong with the code labels Jan 30, 2021
mbyrnepr2 added a commit to mbyrnepr2/astroid that referenced this issue Oct 10, 2022
mbyrnepr2 added a commit to pylint-dev/astroid that referenced this issue Oct 15, 2022
…hods. (#1827)

* Add the ``length`` parameter to ``hash.digest`` & ``hash.hexdigest`` in the ``hashlib`` brain.

* Move content in Changelog to a different section.

Refs pylint-dev/pylint#4039
@mbyrnepr2
Copy link
Member

Can be closed when https://github.com/PyCQA/astroid/milestone/60 is available.

@Pierre-Sassoulas Pierre-Sassoulas added this to the 2.16.0 milestone Oct 15, 2022
Pierre-Sassoulas pushed a commit to pylint-dev/astroid that referenced this issue Oct 19, 2022
…hods. (#1827)

* Add the ``length`` parameter to ``hash.digest`` & ``hash.hexdigest`` in the ``hashlib`` brain.

* Move content in Changelog to a different section.

Refs pylint-dev/pylint#4039
Pierre-Sassoulas pushed a commit to pylint-dev/astroid that referenced this issue Oct 19, 2022
…hods. (#1827)

* Add the ``length`` parameter to ``hash.digest`` & ``hash.hexdigest`` in the ``hashlib`` brain.

* Move content in Changelog to a different section.

Refs pylint-dev/pylint#4039
@mbyrnepr2
Copy link
Member

mbyrnepr2 commented Oct 25, 2022

Can be closed when https://github.com/PyCQA/astroid/milestone/60 is available.

Closing

timmc-edx added a commit to openedx/edx-platform that referenced this issue Feb 13, 2023
- Remove pylint warning suppression from SHAKE-128 hexdigest calls; these
  are no longer needed as of astroid 2.12.12. For background, see issue
  <pylint-dev/pylint#4039>. Also, correct a comment
  that referred to SHAKE-256 instead of SHAKE-128.
- Replace "released" with "beta" in several places where there was a copy
  & paste error in dark_lang. Add mention of `beta_lang` to a docstring
  where it was omitted.
- Remove comment regarding Mongo startup; the code it referred to has since
  been removed.
- Fix typo.
timmc-edx added a commit to openedx/edx-platform that referenced this issue Feb 13, 2023
- Remove pylint warning suppression from SHAKE-128 hexdigest calls; these
  are no longer needed as of astroid 2.12.12. For background, see issue
  <pylint-dev/pylint#4039>. Also, correct a comment
  that referred to SHAKE-256 instead of SHAKE-128.
- Replace "released" with "beta" in several places where there was a copy
  & paste error in dark_lang. Add mention of `beta_lang` to a docstring
  where it was omitted.
- Remove comment regarding Mongo startup; the code it referred to has since
  been removed.
- Fix typos.
timmc-edx added a commit to openedx/edx-platform that referenced this issue Feb 14, 2023
- Remove pylint warning suppression from SHAKE-128 hexdigest calls; these
  are no longer needed as of astroid 2.12.12. For background, see issue
  <pylint-dev/pylint#4039>. Also, correct a comment
  that referred to SHAKE-256 instead of SHAKE-128.
- Replace "released" with "beta" in several places where there was a copy
  & paste error in dark_lang. Add mention of `beta_lang` to a docstring
  where it was omitted.
- Remove comment regarding Mongo startup; the code it referred to has since
  been removed.
- Fix typos.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 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
Development

No branches or pull requests

4 participants