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

Skip site-packages dirs for pep8 #788

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format mostly follows [Keep a Changelog](http://keepachangelog.com/en/1.0.0/
- Fix documentation for watching Github tags and releases, again (#723)
- Fix `--test-reporter` command-line option so `separate` configuration option is no longer ignored when sending test notifications (#772, by marunjar)
- Fix line height and dark mode regression (#774 reported by kongomongo, PRs #777 and #778 by trevorshannon)
- Fix pep8 test to ignore files in the site-packages directory for cases where the venv is in the project directory (#788 by jamstah)

## [2.28] -- 2023-05-03

Expand Down
15 changes: 13 additions & 2 deletions lib/urlwatch/tests/test_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,19 @@ def test_pep8_conformance():
import pycodestyle
style = pycodestyle.StyleGuide(ignore=['E501', 'E402', 'W503', 'E241'])

py_files = [y for x in os.walk(os.path.abspath('.')) for y in glob(os.path.join(x[0], '*.py'))]
result = style.check_files(py_files)
import site
site_packages = site.getsitepackages()

def py_files():
for dir, dirs, files in os.walk(os.path.abspath('.')):
if dir in site_packages:
dirs.clear() # os.walk lets us modify the dirs list to prune the walk
files.clear() # we also don't want to process files in the root of this excluded dir
for file in files:
if file.endswith('.py'):
yield os.path.join(dir, file)

result = style.check_files(py_files())
assert result.total_errors == 0, "Found #{0} code style errors".format(result.total_errors)


Expand Down
Loading