Skip to content

Conversation

@winstxnhdw
Copy link
Contributor

@winstxnhdw winstxnhdw commented Nov 15, 2025

As mentioned here, we default to selecting all lint rules.

Summary by Sourcery

Modernize project configuration and code style by defaulting to all Ruff lint rules, adopting PEP 585 generics throughout, cleaning up test parametrization, and synchronizing documentation with these changes.

Enhancements:

  • Default Ruff lint rules to select all by using "ALL" in the pyproject.toml configuration
  • Migrate type annotations across code, benchmarks, and tests to PEP 585 built-in generics and add explicit return types for benchmark functions
  • Simplify pytest parametrize decorators and update test signatures to use list[tuple[str, str]] annotations
  • Use named argument parse_numbers in parse_url_encoded_dict calls

Documentation:

  • Update README snippet to reflect the new PEP 585 type annotations

@sourcery-ai
Copy link

sourcery-ai bot commented Nov 15, 2025

Reviewer's Guide

This PR refactors the Ruff lint config to use a catch-all rule, modernizes type hints to PEP 585 generics, cleans up test parameterization and benchmarks for consistency, switches to named boolean flags in parse_url_encoded_dict calls, and trims redundant badges in the README.

Class diagram for updated type hints in benchmarks.py

classDiagram
    class parse_url_encoded_form_data {
        +parse_url_encoded_form_data(encoded_data: bytes) dict[str, Any]
    }
    class bench_qsl {
        +bench_qsl(runner: pyperf.Runner) None
    }
    class bench_qs {
        +bench_qs(runner: pyperf.Runner) None
    }
    parse_url_encoded_form_data --> "defaultdict[str, list[Any]]" DefaultDict
    parse_url_encoded_form_data --> "loads" JSONDecode
    bench_qsl --> "pyperf.Runner" Runner
    bench_qs --> "pyperf.Runner" Runner
Loading

File-Level Changes

Change Details Files
Simplify Ruff lint rule selection
  • Replace explicit rule list with select = ["ALL"]
  • Remove individual lint codes and rely on default all-rule behavior
pyproject.toml
Modernize type hints and function signatures
  • Switch typing imports (List, Dict, DefaultDict, Tuple) to built-in generics (list, dict, defaultdict, tuple)
  • Add explicit → None return annotations on benchmark functions
  • Adjust literal container syntax (use [] instead of ())
benchmarks.py
README.md
tests/test_parse_qsl.py
Clean up pytest parameterization in parse_qsl tests
  • Change param names from comma-separated string to tuple literal
  • Remove duplicated test entries in parameter lists
tests/test_parse_qsl.py
Use named flags for parse_numbers in parse_url_encoded_dict
  • Replace positional True/False with parse_numbers=True/False
tests/test_parse_qs.py
Update README meta badges
  • Remove the Black code style badge from the Meta section
  • Streamline badge formatting in the README table
README.md

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!

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

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 there - I've reviewed your changes - here's some feedback:

  • The new PEP585-style generics (e.g. list[tuple[str, str]]) aren’t supported on Python 3.8 as declared in your config—either revert to typing.List/Tuple or bump the minimum Python version.
  • In the README code snippet you imported list from typing, which is invalid—switch that import to List (or remove it and use the built-in list) to avoid errors.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The new PEP585-style generics (e.g. list[tuple[str, str]]) aren’t supported on Python 3.8 as declared in your config—either revert to typing.List/Tuple or bump the minimum Python version.
- In the README code snippet you imported `list` from typing, which is invalid—switch that import to `List` (or remove it and use the built-in list) to avoid errors.

## Individual Comments

### Comment 1
<location> `benchmarks.py:38-40` </location>
<code_context>

 def parse_url_encoded_form_data(encoded_data: bytes) -> Dict[str, Any]:
     """Parse an url encoded form data into dict of parsed values"""
-    decoded_dict: DefaultDict[str, List[Any]] = defaultdict(list)
+    decoded_dict: DefaultDict[str, list[Any]] = defaultdict(list)
     for k, v in parse_qsl(encoded_data.decode(), keep_blank_values=True):
</code_context>

<issue_to_address>
**issue:** Using built-in generic types for defaultdict may impact compatibility with older Python versions.

This type annotation is only supported in Python 3.9 and above; consider using the older syntax if you need compatibility with earlier versions.
</issue_to_address>

### Comment 2
<location> `README.md:130` </location>
<code_context>


 def parse_url_encoded_form_data(encoded_data: bytes) -> Dict[str, Any]:
     """Parse an url encoded form data into dict of parsed values"""
-    decoded_dict: DefaultDict[str, List[Any]] = defaultdict(list)
+    decoded_dict: DefaultDict[str, list[Any]] = defaultdict(list)
</code_context>

<issue_to_address>
**issue (typo):** Change 'an url' to 'a url' in the docstring for correct grammar.

Replace 'an' with 'a' before 'url' in the docstring for grammatical accuracy.

```suggestion
    """Parse a url encoded form data into dict of parsed values"""
```
</issue_to_address>

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.

winstxnhdw and others added 2 commits November 15, 2025 18:08
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
Signed-off-by: Winston H. <56998716+winstxnhdw@users.noreply.github.com>
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