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 warnings #6659

Merged
merged 4 commits into from Oct 23, 2022
Merged

pylint warnings #6659

merged 4 commits into from Oct 23, 2022

Conversation

marksmayo
Copy link
Contributor

@marksmayo marksmayo commented Oct 13, 2022

Fixed some pylint issues

Fixes # unnecessary elses, conditional checks, import structure and encodings

Changes proposed in this pull request:

  • fixes to pylint warnings

@marksmayo
Copy link
Contributor Author

Not quite sure what to do about the coverage - it's not like I changed functionality much, per se

@radarhere radarhere changed the title some pylint warnings pylint warnings Oct 13, 2022
@radarhere
Copy link
Member

I've created PR #6660 to help one of the missing coverage lines. As for the other, it's being skipped on CI jobs, so there's nothing to do there.

Comment on lines 240 to 246
def test_truncated_file(tmp_path):
# Test EOF in header
path = str(tmp_path / "temp.pgm")
with open(path, "w") as f:
with open(path, "w", encoding="utf-8") as f:
f.write("P6")

with pytest.raises(ValueError) as e:
Copy link
Contributor

Choose a reason for hiding this comment

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

ppm/pgm files are either ASCII or binary. Since we're writing text here we should probably use "ascii".

Copy link
Member

Choose a reason for hiding this comment

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

Since this is P6, it is binary.

I've created PR #6677 to change this to write in binary format.

@hugovk hugovk added the Cleanup label Oct 13, 2022
@radarhere
Copy link
Member

Just checking - so are we adding another linting standard? I had thought the idea behind using black was to end style debates.

#3733 (comment)

I'd like to suggest formatting the code with Black:

By using Black, you agree to cede control over minutiae of hand-formatting. In return, Black gives you speed, determinism, and freedom from pycodestyle nagging about formatting. You will save time and mental energy for more important matters.

They will not always agree.

https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#pylint

Pylint is also a code linter like Flake8. It has the same checks as flake8 and more. In particular, it has more formatting checks regarding style conventions like variable naming. With so many checks, Pylint is bound to have some mixed feelings about Black’s formatting style.

Copy link
Member

@hugovk hugovk left a comment

Choose a reason for hiding this comment

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

Black is about style, generally about whitespace and doesn't touch the AST, whereas Pylint is a static code analyser, and also checks for code deprecations. It can help find bugs.

Pylint has lots of suggestions, and should be evaluated on a case-by-case basis.

For example, we're not going to change:

C0103: Variable name "im" doesn't conform to snake_case naming style (invalid-name)

I think these changes are fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants