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

Issue 3241: CLI tool to explain violations #3256

Open
wants to merge 34 commits into
base: master
Choose a base branch
from

Conversation

Tapeline
Copy link
Contributor

@Tapeline Tapeline commented Jan 5, 2025

I have made things!

Checklist

  • I have double checked that there are no unrelated changes in this pull request (old patches, accidental config files, etc)
  • I have created at least one test case for the changes I have made
  • I have updated the documentation for the changes I have made
  • I have added my changes to the CHANGELOG.md

Related issues

#3241 CLI tool to explain issues

🙏 Please, if you or your company is finding wemake-python-styleguide valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/wemake-python-styleguide. As a thank you, your profile/company logo will be added to our main README which receives hundreds of unique visitors per day.

Copy link
Member

@sobolevn sobolevn left a comment

Choose a reason for hiding this comment

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

Thanks! There's a lot of work ahead, this is not a full review :)
I will look again tomorrow.

docs/pages/usage/cli.rst Outdated Show resolved Hide resolved
wemake_python_styleguide/cli/application.py Outdated Show resolved Hide resolved
wemake_python_styleguide/cli/application.py Show resolved Hide resolved
wemake_python_styleguide/cli/commands/base.py Outdated Show resolved Hide resolved
@sobolevn
Copy link
Member

sobolevn commented Jan 5, 2025

Please, rebase your PR.

@Tapeline Tapeline changed the title Issue 3241 Issue 3241: CLI tool to explain violations Jan 6, 2025
Tapeline and others added 23 commits January 6, 2025 13:10
Add explain command
# Conflicts:
#	CHANGELOG.md
#	docs/pages/usage/cli.rst
#	wemake_python_styleguide/cli/application.py
#	wemake_python_styleguide/cli/commands/base.py
#	wemake_python_styleguide/cli/commands/explain/command.py
#	wemake_python_styleguide/cli/commands/explain/message_formatter.py
#	wemake_python_styleguide/cli/commands/explain/violation_loader.py
Add explain command (with code review and updated docs)
# Conflicts:
#	CHANGELOG.md
#	docs/pages/usage/cli.rst
#	poetry.lock
#	tests/test_cli/test_explain.py
#	wemake_python_styleguide/cli/application.py
#	wemake_python_styleguide/cli/cli_app.py
#	wemake_python_styleguide/cli/commands/explain/message_formatter.py
#	wemake_python_styleguide/cli/commands/explain/violation_loader.py
#	wemake_python_styleguide/cli/output.py
# Conflicts:
#	tests/test_cli/test_explain.py
Copy link

codecov bot commented Jan 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c97b4b7) to head (c037010).

Additional details and impacted files
@@            Coverage Diff             @@
##            master     #3256    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          348       356     +8     
  Lines        11537     11747   +210     
  Branches       795       803     +8     
==========================================
+ Hits         11537     11747   +210     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Tapeline
Copy link
Contributor Author

Tapeline commented Jan 11, 2025

Added more tests, coverage now is 100%.

Also spotted an issue with .pre-commit-config.yml: while all other config files exclude something like tests/**/__snapshots__/** (that is, all files in __snapshots__ directories), the pre-commit config only excludes (cite) ^(tests/fixtures/|tests/test_formatter/__snapshots__/), which leads to snapshot files being reformatted and broken. Costed me an hour to debug and figure out what was wrong)

@Tapeline Tapeline requested a review from sobolevn January 16, 2025 21:56
.pre-commit-config.yaml Outdated Show resolved Hide resolved
.readthedocs.yml Outdated Show resolved Hide resolved
pyproject.toml Outdated Show resolved Hide resolved
tests/test_cli/__snapshots__/test_explain.ambr Outdated Show resolved Hide resolved
tests/test_cli/__snapshots__/test_explain.ambr Outdated Show resolved Hide resolved
@Tapeline Tapeline requested a review from sobolevn January 21, 2025 16:11
tests/test_cli/test_explain.py Show resolved Hide resolved
wemake_python_styleguide/cli/output.py Show resolved Hide resolved

def _is_a_violation(class_object) -> bool:
"""Dumb check if class is a violation class."""
return hasattr(class_object, 'code')
Copy link
Member

Choose a reason for hiding this comment

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

We can use isinstance with BaseViolation, it would be more correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some subclasses of BaseViolation that are not actual violation classes. So that hasattr check is needed anyway

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.

2 participants