Skip to content

chore: switch to ruff#107

Open
max-wittig wants to merge 2 commits intomasterfrom
chore-switch-to-ruff
Open

chore: switch to ruff#107
max-wittig wants to merge 2 commits intomasterfrom
chore-switch-to-ruff

Conversation

@max-wittig
Copy link
Member

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @max-wittig, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the project's development environment by adopting ruff as the primary tool for linting and formatting, replacing older, separate tools. This change aims to improve code consistency and developer experience. Concurrently, several core project dependencies have been upgraded to newer versions, ensuring the application runs on up-to-date infrastructure components and Python runtime.

Highlights

  • Tooling Migration: The project's code formatting and linting tools have been migrated from black, isort, and flake8 to ruff, streamlining the development dependency stack.
  • Dependency Updates: Key dependencies including the Python version, Sentry submodule, and Docker images for Postgres and Redis have been updated to their latest versions.
  • Code Refinements: Minor code changes were applied across several Python files, primarily involving import reordering, string formatting updates, and if/else to ternary conversions, likely as a result of ruff's application.
Changelog
  • .gitmodules
    • Updated Sentry submodule branch from 26.2.0 to 26.2.1.
  • .python-version
    • Updated the required Python version from 3.13.5 to 3.14.3.
  • deps/sentry
    • Updated the Sentry subproject commit hash.
  • docker-compose.yml
    • Updated the Postgres image version from 18.1 to 18.2.
    • Updated the Redis image version from 8.4.0-alpine to 8.6.1-alpine.
  • oidc/constants.py
    • Consolidated a multi-line string assignment into a single line.
  • oidc/provider.py
    • Reordered import statements for collections.abc.Callable and django.http.HttpRequest.
    • Refactored an if/else statement for version assignment into a ternary expression.
    • Corrected the retry loop condition from 10 < retry to retry > 10.
  • oidc/views.py
    • Reordered import statements for django.http.HttpRequest and sentry.utils.json.
    • Updated string formatting in logger.error calls to use f-strings.
    • Refactored an if/else statement for domain assignment into a ternary expression.
  • pyproject.toml
    • Replaced black, isort, and flake8 development dependencies with ruff.
    • Added ruff configuration including line-length, extend-exclude, extend-ignore rules, and select options for various linters.
  • setup.cfg
    • Removed the flake8 configuration section.
  • uv.lock
    • Removed black, click, flake8, isort, mccabe, mypy-extensions, pathspec, platformdirs, pycodestyle, pyflakes, and pytokens packages.
    • Added ruff package with version 0.15.2 and its associated hashes.
Ignored Files
  • Ignored by pattern: .github/workflows/** (2)
    • .github/workflows/publish.yml
    • .github/workflows/test.yml
Activity
  • No specific activity (comments, reviews, progress) has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request migrates the project from using black, isort, and flake8 to ruff for code formatting and linting. The configuration changes and dependency updates are appropriate for this switch. Most of the code changes are stylistic improvements applied by ruff. However, I've identified a critical logical bug in the retry mechanism in oidc/provider.py that was present before but is highlighted by the code reformatting. Please see the specific comment for details.

retry_codes = [429, 500, 502, 503, 504]
for retry in range(10):
if 10 < retry:
if retry > 10:

Choose a reason for hiding this comment

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

critical

This condition retry > 10 will never be true within a for retry in range(10) loop, as retry will only take values from 0 to 9. This makes the check and the return {} statement on the next line unreachable (dead code).

If all 10 retries fail, the loop completes and the function implicitly returns None. This will cause an AttributeError in build_identity when it attempts to call .get() on the None return value.

To fix this, you should remove this if block and instead return {} after the loop to handle the case where all retries are exhausted.

Copy link
Member Author

Choose a reason for hiding this comment

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

As I didn't change the meaning of this code here, let's not modify it.

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.

1 participant