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

Merged
merged 55 commits into from
Jan 28, 2025

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.

@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
@Tapeline Tapeline requested a review from sobolevn January 24, 2025 13:25
@Tapeline
Copy link
Contributor Author

Applied all changes except removing hasattr check (reasoning provided).
Thank you for patiently reviewing my code)

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.

Thank you! Looks like that this is the ~last review round :)

@Tapeline Tapeline requested a review from sobolevn January 25, 2025 12:57
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.

I saw some new things to improve 😊

universal_newlines=True,
encoding=encoding,
env=os.environ,
shell=True,
Copy link
Member

Choose a reason for hiding this comment

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

why do we need shell= and env=?

Copy link
Member

Choose a reason for hiding this comment

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

Marking as not really resolved. I think that we might need to use shell=True because wps is not locatable without the PATH, right?

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.

We are almost there! This is going to be an amazing feature, thanks a lot to your for delivering it! 👍

universal_newlines=True,
encoding=encoding,
env=os.environ,
shell=True,
Copy link
Member

Choose a reason for hiding this comment

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

Marking as not really resolved. I think that we might need to use shell=True because wps is not locatable without the PATH, right?

@Tapeline
Copy link
Contributor Author

Also thought about a slight improvement: we can add a shorthand for explain subcommand. It may be wps e, for example

@sobolevn
Copy link
Member

I don't think that adding some shorthands is actually a good thing :)

Tapeline and others added 3 commits January 27, 2025 01:35
…textwrap library. Add typed arguments for subcommands
# Conflicts:
#	tests/test_cli/test_explain.py
#	tests/test_cli/test_explain_internals.py
#	wemake_python_styleguide/cli/cli_app.py
#	wemake_python_styleguide/cli/commands/explain/message_formatter.py
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!

# Conflicts:
#	wemake_python_styleguide/cli/application.py
#	wemake_python_styleguide/cli/commands/base.py
#	wemake_python_styleguide/cli/commands/explain/command.py
@Tapeline Tapeline requested a review from sobolevn January 27, 2025 17:52
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.

Thank you!


def get_violation_submodules() -> Collection[ModuleType]:
"""Get all possible violation submodules."""
return _safely_get_all_submodules(_VIOLATION_MODULE_BASE)
Copy link
Member

Choose a reason for hiding this comment

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

Do we really need _safely_get_all_submodules? It is used in a single place, but all this function does is calling _safely_get_all_submodules

So, let's just remove _safely_get_all_submodules and move all code to get_violation_submodules

@sobolevn sobolevn merged commit dffbb62 into wemake-services:master Jan 28, 2025
9 checks passed
@sobolevn
Copy link
Member

You did a great job here, awesome feature! Thanks a lot for your patience during the review time :)

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