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

Fix for pycodestyle not picking up modules in non-package dirs #199

Closed
wants to merge 12 commits into from
Closed

Conversation

hjoukl
Copy link

@hjoukl hjoukl commented Dec 7, 2016

As reported in #179, the pycodestyle/pep8 tool fails to

  • check Python files in the root PATH directory
  • non-package directories in PATH
    when driven by prospector.

See the comments to #179 for more discussion.

This PR takes the simple approach of using found_files.iter_module_paths() for explicit files
mode and rootpath for "single directory arg" mode (leaving file lookup to
pep8/pycodestyle) instead of iter_package_paths().

Comes with extensive tests, also adding a bunch of tests for the general finder functionality.

Edit: PR looks intimidating now judging by the number of commits, but note that the actual changes to the
prospector codebase are small - it's mostly test additions... ;-)

Holger Joukl added 10 commits November 22, 2016 09:42
Adding tests for the iter_[file|package|directory|module]_paths() methods
of FoundFiles and SingleFiles, with an appropriate test data directory tree.
Tests the current status quo of method results.
Adding myself to CONTRIBUTORS.md.
Fixing the order of the _find_paths() return value assignment to result
variables and the parameter order for the FoundFiles initialization to
the correct order files, modules, packages, directories.
Note that the double error actually evened out i.e. the failure was not
visible.
Test expections are set so this tests ok with the current behaviour, for now.
This will need to change as pep8 tool ignores python modules in non-package
directories when invoked with a single dir PATH command line arg.
…tions.

Now set up to fail for the current incorrect behaviour of silently ignoring
modules in non-package directories (#179).
Instead of iter_package_paths() use iter_module_paths() for explicit files
mode and rootpath for "single directory arg" mode (leaving file lookup to
pep8/pycodestyle).
@coveralls
Copy link

coveralls commented Dec 7, 2016

Coverage Status

Changes Unknown when pulling 9f7e523 on hjoukl:develop into ** on landscapeio:develop**.

@hjoukl
Copy link
Author

hjoukl commented Dec 7, 2016

S.th. amiss with the code-quality/landscape results reporting? If I follow the Details link everything seems fine, even a slight "score increased" is shown.

@coveralls
Copy link

coveralls commented Jan 4, 2017

Coverage Status

Changes Unknown when pulling 0836e8f on hjoukl:develop into ** on landscapeio:develop**.

This is not necessary here as os.path.abspath() is now ensured in the tool
configuration, i.e. by _iter_module_paths() for multiple file PATH args and
explicitly for a single dir PATH arg.
@coveralls
Copy link

coveralls commented Jan 4, 2017

Coverage Status

Changes Unknown when pulling a666605 on hjoukl:develop into ** on landscapeio:develop**.

@carlio
Copy link
Member

carlio commented May 2, 2017

Fantasic PR and report, thank you very much. I am finally getting to dealing with all the built-up problems so will check this out and merge soon.

@harrisont
Copy link

Looking forward to this fix. Anything blocking it from being merged?

@chocoelho
Copy link
Contributor

I'm currently reviewing this PR, just FYI, hope to merge it soon.

@chocoelho chocoelho self-requested a review August 31, 2019 19:27
@chocoelho chocoelho removed their request for review July 30, 2020 18:19
@cclauss
Copy link
Contributor

cclauss commented Aug 28, 2021

Please resolve conflicts.

@Pierre-Sassoulas
Copy link
Collaborator

I won't be able to okay this one it's too technical for me. Please be mindful of your time @hjoukl :)

@hjoukl
Copy link
Author

hjoukl commented Jan 10, 2022

Hi @carlio, @chocoelho, @Pierre-Sassoulas, happy to see this gain traction again.

Alas, this PR has become pretty rusty and at this point I'm unsure how it can be best brought up-to-date. For one I'm unsure if the initial problem reported in #179 persists(?), since 58f9486#diff-e7bec612b6b0afbed5f7116cdb3147775c8262078970c4cddb6d5efe5c0258b7 made significant changes to relevant parts of the affected code.

Second, I noticed a big refactoring going on in the develop branch which looks like it makes rebasing quite hard, wrt the finder.py changes and tests.

So: What to base this upon in the 1st place - the head of the development branch?
Looks to me like I basically needed to cherry-pick and adapt the test additions (original PR consists mainly of test code), see if the problem is still provoked by the additional tests and then look how it could be fixed. Going down this route I would probably abandon this PR in favor of a new one. No promises, though ;-)

What d'ya think?

@Pierre-Sassoulas
Copy link
Collaborator

What d'ya think?

I'd at least try to rebase first before re-doing everything, but think you're the one who knows best 😄

@carlio
Copy link
Member

carlio commented Jan 10, 2022

@hjoukl I'd hold off on this for now, as I have a big fat branch with lots of changes including swapping to using pathlib for path-related things. I'll should create a draft PR for visibility, it's living on my own repo for now!

@hjoukl
Copy link
Author

hjoukl commented Jan 12, 2022

@carlio, @Pierre-Sassoulas Thanks for the infos - feel free to ping me when these pathlib changes have landed. I'd then try and add the adapted original tests.

@carlio carlio added the file-finder-rewrite The plan to replace the file finder in prospector should include this bug label Mar 1, 2022
@carlio
Copy link
Member

carlio commented Mar 12, 2022

@hjoukl The pathlib changes is now in the develop branch

I was able to reproduce your issue, and the new code does not appear to have that problem any more. Please do try it out and if you still have it let me know!

I've got a couple of other bugfixes I want to get in before I release this code as an RC.

@carlio
Copy link
Member

carlio commented Mar 13, 2022

A follow up, but version 1.8.0 rc0 is now on PyPI

@carlio
Copy link
Member

carlio commented Mar 18, 2022

I shall close this because I suspect it is fixed, at least my own tests say it is, but if you try again and find it doesn't work please re-open or create a new issue.

@carlio carlio closed this Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
file-finder-rewrite The plan to replace the file finder in prospector should include this bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants