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 finding W101 error on commented out code #10198

Closed
panewt opened this issue Jan 22, 2025 · 2 comments
Closed

pylint finding W101 error on commented out code #10198

panewt opened this issue Jan 22, 2025 · 2 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@panewt
Copy link

panewt commented Jan 22, 2025

Bug description

#!/usr/bin/python3 -B

def main():
    theMsg = 'a message we want to use for a RuntimeError'
    raise RuntimeError (theMsg)
    """
    some code that pylint shouldn't be scanning
    """

if __name__ == '__main__':
    main()

Configuration

Command used

pylint-3 per rocky9

Pylint output

[paul@grotto python]$ pylint CENSUS_household.py 
running pylint-3
************* Module CENSUS_household
CENSUS_household.py:2432:3: W0101: Unreachable code (unreachable)
CENSUS_household.py:2441:3: W0101: Unreachable code (unreachable)

------------------------------------------------------------------
Your code has been rated at 9.99/10 (previous run: 9.99/10, +0.00)

[paul@grotto python]$

Expected behavior

The line pylint is barking on is a comment and therefore it should care whether code flow treats this line as unreachable

Note that I am not running the most current versions of Python and pylint as I only have what RHEL/rocky 9.5 will give me. So if you have already corrected this, I apologize for the noise

Pylint version

[paul@grotto python]$ pylint --version
running pylint-3
pylint 2.13.7
astroid 2.11.6
Python 3.9.21 (main, Dec  5 2024, 00:00:00) 
[GCC 11.5.0 20240719 (Red Hat 11.5.0-2)]
[paul@grotto python]$

OS / Environment

Rocky Linux release 9.5 (Blue Onyx)

Additional dependencies

@panewt panewt added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Jan 22, 2025
@Pierre-Sassoulas
Copy link
Member

I think pylint is working as intended this is not a comment but a string declaration that is not assigned to a variable ? (A comment should be # something). Docstrings should not be in the middle of the code but at the module beginning and after function declaration.

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Jan 25, 2025

Closing following discussion in #10197

@Pierre-Sassoulas Pierre-Sassoulas closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

2 participants