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

chore: setup ruff #252

Draft
wants to merge 2 commits into
base: poetry
Choose a base branch
from
Draft

chore: setup ruff #252

wants to merge 2 commits into from

Conversation

JaeAeich
Copy link

@JaeAeich JaeAeich commented Feb 21, 2025

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

Fixes #237
Fixes #238
Fixes #239

Summary by Sourcery

Chores:

  • Configures Ruff, a fast Python linter and formatter, to improve code quality and consistency.

Copy link

sourcery-ai bot commented Feb 21, 2025

Reviewer's Guide by Sourcery

This pull request migrates the project from pip to poetry for dependency management, build process, and applies formatting and linting using ruff.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Replaced pip with poetry for dependency management and build process.
  • Removed requirements.txt, requirements_dev.txt, and requirements_docs.txt.
  • Added pyproject.toml and poetry.lock for poetry configuration.
  • Modified Dockerfile to use poetry for installing dependencies and building the application.
  • Updated .github/workflows/checks.yml to use poetry for linting, type checking, and testing.
  • Removed setup.py and setup.cfg.
tests/security/test_auth.py
tests/security/access_control/test_access_control_server.py
tests/models/test_config.py
docker/Dockerfile
foca/security/auth.py
foca/models/config.py
foca/database/register_mongodb.py
foca/errors/exceptions.py
foca/security/access_control/access_control_server.py
foca/security/access_control/register_access_control.py
examples/petstore-access-control/controllers.py
foca/api/register_openapi.py
tests/security/access_control/test_register_access_control.py
examples/petstore/controllers.py
tests/database/test_register_mongodb.py
tests/security/access_control/foca_casbin_adapter/test_adapter.py
tests/errors/test_errors.py
docs/api/conf.py
tests/utils/test_logging.py
tests/api/test_register_openapi.py
tests/mock_data.py
foca/config/config_parser.py
.github/workflows/checks.yml
foca/factories/connexion_app.py
foca/utils/misc.py
tests/utils/test_db.py
.readthedocs.yaml
tests/config/test_config_parser.py
tests/security/access_control/foca_casbin_adapter/test_casbin_rule.py
foca/security/access_control/foca_casbin_adapter/adapter.py
foca/factories/celery_app.py
foca/utils/logging.py
examples/petstore-access-control/app.py
examples/petstore/app.py
tests/factories/test_connexion_app.py
examples/petstore-access-control/exceptions.py
foca/security/access_control/foca_casbin_adapter/casbin_rule.py
tests/utils/test_misc.py
foca/security/access_control/constants.py
tests/test_files/model_valid.py
tests/test_files/models_petstore.py
foca/security/cors.py
foca/version.py
tests/factories/test_celery_app.py
tests/integration_tests.py
tests/security/test_cors.py
Makefile
Applied formatting and linting using ruff.
  • Applied formatting changes throughout the codebase to adhere to ruff's style guidelines.
  • Addressed linting issues identified by ruff to improve code quality and maintainability.
tests/security/test_auth.py
tests/security/access_control/test_access_control_server.py
tests/models/test_config.py
docker/Dockerfile
foca/security/auth.py
foca/models/config.py
foca/database/register_mongodb.py
foca/errors/exceptions.py
foca/security/access_control/access_control_server.py
foca/security/access_control/register_access_control.py
examples/petstore-access-control/controllers.py
foca/api/register_openapi.py
tests/security/access_control/test_register_access_control.py
examples/petstore/controllers.py
tests/database/test_register_mongodb.py
tests/security/access_control/foca_casbin_adapter/test_adapter.py
tests/errors/test_errors.py
docs/api/conf.py
tests/utils/test_logging.py
tests/api/test_register_openapi.py
tests/mock_data.py
foca/config/config_parser.py
.github/workflows/checks.yml
foca/factories/connexion_app.py
foca/utils/misc.py
tests/utils/test_db.py
.readthedocs.yaml
tests/config/test_config_parser.py
tests/security/access_control/foca_casbin_adapter/test_casbin_rule.py
foca/security/access_control/foca_casbin_adapter/adapter.py
foca/factories/celery_app.py
foca/utils/logging.py
examples/petstore-access-control/app.py
examples/petstore/app.py
tests/factories/test_connexion_app.py
examples/petstore-access-control/exceptions.py
foca/security/access_control/foca_casbin_adapter/casbin_rule.py
tests/utils/test_misc.py
foca/security/access_control/constants.py
tests/test_files/model_valid.py
tests/test_files/models_petstore.py
foca/security/cors.py
foca/version.py
tests/factories/test_celery_app.py
tests/integration_tests.py
tests/security/test_cors.py
Makefile

Assessment against linked issues

Issue Objective Addressed Explanation
#237 Use Black to auto-format code. The PR uses ruff, not black, to format code.
#237 Include code style check in CI workflow.
#238 Use Pylint to refactor code. The PR uses ruff, not pylint, to refactor code.
#238 Include code style check in CI workflow. The PR sets up ruff, not pylint, in the CI workflow.
#239 Use flake8-docstrings to check docstring style. The PR sets up ruff, a linter, but does not specifically configure or use flake8-docstrings for docstring style checking.
#239 Include docstring style check in CI workflow. While the PR sets up ruff in CI, it doesn't configure it to specifically check docstring style, nor does it mention flake8-docstrings.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@JaeAeich JaeAeich changed the base branch from dev to poetry February 21, 2025 03:25
@JaeAeich
Copy link
Author

@sourcery-ai summary

@JaeAeich JaeAeich marked this pull request as draft February 21, 2025 03:26
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @JaeAeich - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider using poetry to manage dependencies instead of requirements.txt and setup.py.
  • Consider using black or ruff format to automatically format the code.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +102 to +113
# [tool.ruff.lint]
# select = [
# "B", # flake8-bugbear
# "C90", # mccabe
# "D", # pydocstyle
# "E", # pycodestyle
# "F", # Pyflakes
# "I", # isort
# "PL", # pylint
# "SIM", # flake8-simplify
# "UP", # pyupgrade
# ]
Copy link
Author

Choose a reason for hiding this comment

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

Note the huge fle changes when I have commented all the extra rules that we use or try to make standard.

Copy link
Author

Choose a reason for hiding this comment

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

Also yes most changes currently are quotation change, but even if I disable the quatation change rule, we would still have similar number of file changes.

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