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

Lint all files in a directory #5676

Closed
wants to merge 2 commits into from

Conversation

matusvalo
Copy link
Collaborator

@matusvalo matusvalo commented Jan 13, 2022

Type of Changes

Type
πŸ› Bug fix
βœ“ ✨ New feature
πŸ”¨ Refactoring
πŸ“œ Docs

Description

This PR adds new parameter --discover-files which switches pylint into mode when it iterates over FS subtree and executes pylint on all .py files within this subtree regardless they are in package or not. But in the other hand this PR honours package name in the final output.

Example consider following subtree:

- test
     `+- a.py
      +- b.py
      +- c
          `+- __init__.py
           +- d.py 

The pylint output with no switch will be following:

$ pylint test
************* Module test
test/__init__.py:1:0: F0010: error while code parsing: Unable to load file test/__init__.py:
[Errno 2] No such file or directory: 'test/__init__.py' (parse-error)

The pylint output with switch will be following:

Note: Each file contains single line simulating error 1 == 1

$ pylint --discover-files test
************* Module a
test/a.py:1:0: W0104: Statement seems to have no effect (pointless-statement)
test/a.py:1:0: R0124: Redundant comparison - 1 == 1 (comparison-with-itself)
************* Module b
test/b.py:1:0: W0104: Statement seems to have no effect (pointless-statement)
test/b.py:1:0: R0124: Redundant comparison - 1 == 1 (comparison-with-itself)
************* Module c
test/c/__init__.py:1:0: W0104: Statement seems to have no effect (pointless-statement)
test/c/__init__.py:1:0: R0124: Redundant comparison - 1 == 1 (comparison-with-itself)
************* Module c.d
test/c/d.py:1:0: W0104: Statement seems to have no effect (pointless-statement)
test/c/d.py:1:0: R0124: Redundant comparison - 1 == 1 (comparison-with-itself)

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

Closes #352

@matusvalo matusvalo marked this pull request as draft January 13, 2022 22:05
Copy link
Member

@Pierre-Sassoulas Pierre-Sassoulas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not look into detail but this looks promising, thank you @matusvalo. #352 is the base issue, #4217 is another approach for reference and it would need to be closed if we merge this.

@Pierre-Sassoulas Pierre-Sassoulas added Enhancement ✨ Improvement to a component Command line Related to command line interface labels Jan 13, 2022
@matusvalo
Copy link
Collaborator Author

matusvalo commented Jan 13, 2022

This PR is now in draft mode. Pending points:

  • Fix CI, implement tests
  • Fine tune code - type annotations, docstrings etc.
  • Finish documentation

I would like to ask just for high level review whether the approach is right one.

@Pierre-Sassoulas Pierre-Sassoulas added the Needs review πŸ” Needs to be reviewed by one or multiple more persons label Jan 13, 2022
@matusvalo
Copy link
Collaborator Author

matusvalo commented Jan 13, 2022

I did not look into detail but this looks promising, thank you @matusvalo. #352 is the base issue, #4217 is another approach for reference and it would need to be closed if we merge this.

I missed #4217 since it is not linked to the issue. I let the decision to maintainers which PR should be finished (or maybe merged together - I had not look into #4217 yet). Please let me know what is your preference.

@Pierre-Sassoulas
Copy link
Member

The other PR got stalled for a long time because of this scary comment. (I've not looked at the issue for a long time and maybe not sufficiently in depth at the time but it seems it was overwhelming for the original implementer). Do you think this would be a problem with your approach ?

@matusvalo
Copy link
Collaborator Author

The other PR got stalled for a long time because of this scary comment. (I've not looked at the issue for a long time and maybe not sufficiently in depth at the time but it seems it was overwhelming for the original implementer). Do you think this would be a problem with your approach ?

I will check that.

@matusvalo
Copy link
Collaborator Author

@Pierre-Sassoulas I have created additional PR trying to solve the issue with problems around sys.path adjustments. Please have a look. My apologies for so many parallel opened PRs, but I am still not sure which approach is the best.

@matusvalo
Copy link
Collaborator Author

matusvalo commented Jan 15, 2022

Closing in favour of #5682

@matusvalo matusvalo closed this Jan 15, 2022
@matusvalo matusvalo deleted the discover_modules branch January 15, 2022 21:05
@Pierre-Sassoulas Pierre-Sassoulas removed the Needs review πŸ” Needs to be reviewed by one or multiple more persons label Jan 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Command line Related to command line interface Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging this pull request may close these issues.

lint all files in a directory
3 participants