[flake8-bugbear] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)#15549
Merged
MichaReiser merged 1 commit intoastral-sh:mainfrom Jan 17, 2025
guillaumeLepape:b903_suggestion
Merged
[flake8-bugbear] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)#15549MichaReiser merged 1 commit intoastral-sh:mainfrom guillaumeLepape:b903_suggestion
flake8-bugbear] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)#15549MichaReiser merged 1 commit intoastral-sh:mainfrom
guillaumeLepape:b903_suggestion
Conversation
…nt is present and target-python version is less or equals than 3.9
flake8-bugbear\] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)flake8-bugbear] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)
Contributor
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| B903 | 1 | 0 | 1 | 0 | 0 |
MichaReiser
reviewed
Jan 17, 2025
Member
MichaReiser
left a comment
There was a problem hiding this comment.
Perfect, and the ecosystem check confirms that this resolves a false positive. Thank you so much!
dcreager
added a commit
that referenced
this pull request
Jan 17, 2025
* main: [red-knot] Inline `SubclassOfType::as_instance_type_of_metaclass()` (#15556) [`flake8-comprehensions`] strip parentheses around generators in `unnecessary-generator-set` (`C401`) (#15553) [`pylint`] Implement `redefined-slots-in-subclass` (`W0244`) (#9640) [`flake8-bugbear`] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (`B903`) (#15549) [red-knot] `type[T]` is disjoint from `type[S]` if the metaclass of `T` is disjoint from the metaclass of `S` (#15547) [red-knot] Pure instance variables declared in class body (#15515) Update snapshots of #15507 with new annotated snipetts rendering (#15546) [`pylint`] Do not report methods with only one `EM101`-compatible `raise` (`PLR6301`) (#15507) Fix unstable f-string formatting for expressions containing a trailing comma (#15545) Support `knot.toml` files in project discovery (#15505) Add support for configuring knot in `pyproject.toml` files (#15493) Fix bracket spacing for single-element tuples in f-string expressions (#15537) [`flake8-simplify`] Do not emit diagnostics for expressions inside string type annotations (`SIM222`, `SIM223`) (#15405) [`flake8-pytest-style`] Do not emit diagnostics for empty `for` loops (`PT012`, `PT031`) (#15542)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[
flake8-bugbear] Do not raise error if keyword argument is present and target-python version is less or equals than 3.9 (B903)Summary
I have this piece of code in one of my repo
When I did this, I started by using dataclass, although I wanted the 3 arguments of the init function to be keywords only. As dataclass does not support kw_only before python 3.10 (reference https://docs.python.org/3/library/dataclasses.html#module-contents), I ended up writing the init function myself.
With the current implementation of B903, this will raise an error. My suggestion would be not to raise error if an keyword only argument and target-version<=3.9.
Related github issue : #15548
Test Plan
I added a new usecase in
class_as_data_structure.py, a class with keyword only.I tested this file with the target-version = latest python and with python3.9.
With the latest python, I'm expecting error and python3.9 no error should be raised.