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

Adding pre commit #220

Merged
merged 10 commits into from
Feb 15, 2024
Merged

Adding pre commit #220

merged 10 commits into from
Feb 15, 2024

Conversation

emarondan
Copy link

Adding config files first. If I get an OK I will proceed to execute the hooks on all the code and fix it to comply.

tox.ini Outdated Show resolved Hide resolved
tox.ini Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.pre-commit-config.yaml Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 7, 2024

Codecov Report

Merging #220 (99bee2d) into master (1251f26) will not change coverage.
Report is 1 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #220   +/-   ##
=======================================
  Coverage   96.18%   96.18%           
=======================================
  Files           9        9           
  Lines         498      498           
  Branches       94       94           
=======================================
  Hits          479      479           
  Misses          9        9           
  Partials       10       10           
Files Coverage Δ
w3lib/encoding.py 98.57% <100.00%> (ø)
w3lib/html.py 95.49% <100.00%> (ø)
w3lib/http.py 100.00% <100.00%> (ø)
w3lib/url.py 98.70% <100.00%> (ø)
w3lib/util.py 72.22% <100.00%> (ø)

Comment on lines 42 to 43
self.assertIsNotNone(bom_encoding)
self.assertIsNotNone(bom)
Copy link
Member

Choose a reason for hiding this comment

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

This change is breaking mypy, because mypy does not understand self.assert*.

If flake8 complains about asserts, I believe we need to disable that check for all files (we will also use asserts outside tests for mypy’s sake).

I am a bit puzzled because in Scrapy we use asserts often, but I see nothing about ignoring such an error in https://github.com/scrapy/scrapy/blob/master/.flake8 (the ignored errors seem unrelated).

Copy link
Author

Choose a reason for hiding this comment

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

I made that change to avoid a bandit issue. It was something like:

>> Issue: [B101:assert_used] Use of assert detected. The enclosed code will be removed when compiling to optimised byte code.
   Severity: Low   Confidence: High
   CWE: CWE-703 (https://cwe.mitre.org/data/definitions/703.html)
   Location: tests/test_url.py:1063:8
   More Info: https://bandit.readthedocs.io/en/0.0.0/plugins/b101_assert_used.html

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

@Gallaecio Gallaecio Feb 15, 2024

Choose a reason for hiding this comment

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

Excluding tests from bandit checks would also be useful in any repo.

Copy link
Author

Choose a reason for hiding this comment

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

Done in 5390b23

@Gallaecio Gallaecio merged commit 181a70f into scrapy:master Feb 15, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants