-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Implement configuration options runtime-evaluated-decorators
and runtime-evaluated-baseclasses
for flake8-type-checking
#3292
Conversation
This is my first time developing in Rust, so I hope I did everything correctly and not implement stuff inefficiently 🙈 |
Maybe I need to understand the default behavior first: import datetime
import pydantic
class Meta(pedantic.BaseModel):
date: datetime.date does not report any violations. from __future__ import annotations
import datetime
import pydantic
class Meta(pedantic.BaseModel):
date: datetime.date reports |
Your understanding is correct! And it mirrors Python's own behavior. Type annotations in class definitions are evaluated at runtime if you don't use As an example, this code throws a runtime error (note that I've omitted the import pydantic
class Meta(pydantic.BaseModel):
date: datetime.date However, this code does not: from __future__ import annotations
import pydantic
class Meta(pydantic.BaseModel):
date: datetime.date |
Ok great, thank you! |
We might want to report this back to flake8-type-checking because I think it suggests moving type annotations in class definitions into a |
…untime-evaluated-baseclasses` for `flake8-type-checking` see astral-sh#2195
78e842f
to
13f6307
Compare
For reasons I can't quite figure out, I'm unable to push to the branch 😬
|
I pushed some changes to a branch here, any way you could pull them in? |
The changes are: removing the As a nit: should it be Separately: should the decorators apply to functions too? ( And then as a higher-level question: how does this compare to the choices that |
(The author of a PR from a fork has an option to Allow edits from maintainers. @sasanjac must have unchecked it for this PR. Either @sasanjac you can turn that back on in the right sidebar, or @charliermarsh you could open a PR to the PR.) |
Maybe you didn’t sufficiently escape the |
Oh something like that is definitely possible. (I just use |
…iguration-options-from-`flake8-type-checking` Apply PR edits to 3292
Strange, I didn't know you had to explicitly allow this. |
Yeah, that sounds reasonable.
True.
Interesting, I haven't used FastAPI yet but this feature sounds very reasonable and I could look into that.
Yeah, maybe we should document it but I think the new approach is more precise than a blank ignore of imports when a class inherits from another. Also, @sondrelg is very active, even here and open to discussions. I thought we could maybe backport the same behavior to |
The decisions made in flake8-type-checking were originally made because I was using FastAPI and pydantic myself at the time, and I wanted to use the plugin in those projects. I didn't know about any other prominent libraries that evaluated type hints at runtime at the time (but there are several, including In retrospect I also think supporting FastAPI is a little bit of a waste of time. This is a subjective evaluation of course, but the concept of dependencies makes it unreasonably hard to support properly. FastAPI can include arbitrary functions in a type signature like this (from the docs): @app.get("/items/")
async def read_items(commons: dict = Depends(common_parameters)):
return commons And the type hints of the function Basically I think if you're doing a FastAPI project, there are too many places where type hints are evaluated to consider a plugin like flake8-type-checking to be particularly useful. At least it would need to become a much larger, more complex project. Is it really true that all class annotations are evaluated on Python 3.10+? I have several projects without |
I'm haven't really used |
Yeah, here it is up to you to decide if you want to deprecate config options, but I think the way of specifying base classes and decorators that lead to the corresponding type annotations not reported is a) a more generic way, no need to have library specific options and b) more precise because only the affected classes/functions are exempt from the rule. However, the user has to actively put the respective classes/decorators in the config. |
You could, if you were only using that decorator pattern. Unfortunately it's very common to use # users.py
user_router = APIRouter(base='/users')
@user_router.get()
def list_users(): ...
@user_router.get('/{id}')
def retrieve_user(id: UUID): ...
# and so on So one FastAPI project could have |
Decorators for classes might make it possible to whitelist attrs classes from type checking in a reliable way, but if the intention for this feature was to add FastAPI support by whitelisting functions decorated with certain patterns you should probably also have another feature for adding dependencies. I don't think this is a great idea though, because:
This is why I personally think you should focus on adding the features you need to support Pydantic usage for now, and think about remaining patterns later if it comes up 👍 |
Ok cool -- thank you for all the discussion here too, very clarifying for me! I'm happy with what's happening here, let's rock. Thanks for diving into Rust :) |
Does this implementation also work on subclasses? E.g. I have an application with different configs and one base config import pydantic
import utils
class BaseConfig(pydantic.BaseModel):
debug = False
database_url: str
class ProdConfig(BaseConfig):
database_url ="production"
prod_only: utils.Type
class DevConfig(BaseConfig):
debug = True
database_url = "dev" |
No, it wouldn't work for subclasses in the same file like that. It could work if you exported |
Thats a bummer but good to know. Thanks. |
Yeah we can't do that level of type inference yet. We track imports, but we can't track arbitrary base class resolution yet. |
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://github.com/charliermarsh/ruff) | `^0.0.254` -> `^0.0.255` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.255`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.255) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.254...v0.0.255) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`flake8-pie`] Fix PIE802 broken auto-fix with trailing comma by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3402](https://github.com/charliermarsh/ruff/pull/3402) - \[`flake8-pie`] Implement autofix for PIE810 by [@​kyoto7250](https://github.com/kyoto7250) in [https://github.com/charliermarsh/ruff/pull/3411](https://github.com/charliermarsh/ruff/pull/3411) - \[`flake8-bugbear`] Add `flake8-bugbear`'s B030 rule by [@​aacunningham](https://github.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/3400](https://github.com/charliermarsh/ruff/pull/3400) - \[`pycodestyle`] Add E231 by [@​carlosmiei](https://github.com/carlosmiei) in [https://github.com/charliermarsh/ruff/pull/3344](https://github.com/charliermarsh/ruff/pull/3344) - \[`pyupgrade`] Flag deprecated (but renamed) imports in UP035 by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3448](https://github.com/charliermarsh/ruff/pull/3448) - \[`pyupgrade`] Remap ChainMap, Counter, and OrderedDict imports to collections by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3392](https://github.com/charliermarsh/ruff/pull/3392) - \[`pylint`] C1901: compare-to-empty-string by [@​AreamanM](https://github.com/AreamanM) in [https://github.com/charliermarsh/ruff/pull/3405](https://github.com/charliermarsh/ruff/pull/3405) - \[`pylint`] Implement W1508 invalid-envvar-default by [@​latonis](https://github.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3449](https://github.com/charliermarsh/ruff/pull/3449) - \[`pylint`] Implement E1507 invalid-envvar-value by [@​latonis](https://github.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3467](https://github.com/charliermarsh/ruff/pull/3467) ##### Settings - Infer `target-version` from project metadata by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3470](https://github.com/charliermarsh/ruff/pull/3470) - Implement configuration options `runtime-evaluated-decorators` and `runtime-evaluated-base-classes` for `flake8-type-checking` by [@​sasanjac](https://github.com/sasanjac) in [https://github.com/charliermarsh/ruff/pull/3292](https://github.com/charliermarsh/ruff/pull/3292) - Add Azure DevOps as a `--format` option. by [@​StefanBRas](https://github.com/StefanBRas) in [https://github.com/charliermarsh/ruff/pull/3335](https://github.com/charliermarsh/ruff/pull/3335) ##### Bug Fixes - Re-enable the T and C linter prefix selectors by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3452](https://github.com/charliermarsh/ruff/pull/3452) - Treat unary operations on constants as constant-like by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3348](https://github.com/charliermarsh/ruff/pull/3348) - Skip byte-order-mark at start of file by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3343](https://github.com/charliermarsh/ruff/pull/3343) - Don't enforce typing-import rules in .pyi files by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3362](https://github.com/charliermarsh/ruff/pull/3362) - Include entire prefix when reporting rule selector errors by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3375](https://github.com/charliermarsh/ruff/pull/3375) - Handle multi-line fixes for byte-string prefixing by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3391](https://github.com/charliermarsh/ruff/pull/3391) - Catch RET504 usages via decorators by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3395](https://github.com/charliermarsh/ruff/pull/3395) - Ignore multiply-assigned variables in RET504 by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3393](https://github.com/charliermarsh/ruff/pull/3393) - \[FIX] PYI011: recognize `Bool` / `Float` / `Complex` numbers as simple defaults by [@​XuehaiPan](https://github.com/XuehaiPan) in [https://github.com/charliermarsh/ruff/pull/3459](https://github.com/charliermarsh/ruff/pull/3459) - Respect ignores for runtime-import-in-type-checking-block (TCH004) by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3474](https://github.com/charliermarsh/ruff/pull/3474) - Avoid panicking in invalid_escape_sequence by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3338](https://github.com/charliermarsh/ruff/pull/3338) - fix: Emit a more useful error if an `extend` points at a non-existent ruff.toml file. by [@​DanCardin](https://github.com/DanCardin) in [https://github.com/charliermarsh/ruff/pull/3417](https://github.com/charliermarsh/ruff/pull/3417) - Respect `--show-fixes` with `--fix-only` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3426](https://github.com/charliermarsh/ruff/pull/3426) - When "Args" and "Parameters" are present, prefer NumPy style by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3430](https://github.com/charliermarsh/ruff/pull/3430) - Remove empty line after RUF100 auto-fix by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3414](https://github.com/charliermarsh/ruff/pull/3414) - Avoid removing un-aliased exceptions in `OSError`-aliased handlers by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3451](https://github.com/charliermarsh/ruff/pull/3451) - Use a hash to fingerprint GitLab CI output by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3456](https://github.com/charliermarsh/ruff/pull/3456) - Avoid respecting noqa directives when RUF100 is enabled by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3469](https://github.com/charliermarsh/ruff/pull/3469) - Output GitLab paths relative to `CI_PROJECT_DIR` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3475](https://github.com/charliermarsh/ruff/pull/3475) - Implement an iterator for universal newlines by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3454](https://github.com/charliermarsh/ruff/pull/3454) #### New Contributors - [@​sasanjac](https://github.com/sasanjac) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3292](https://github.com/charliermarsh/ruff/pull/3292) - [@​aacunningham](https://github.com/aacunningham) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3380](https://github.com/charliermarsh/ruff/pull/3380) - [@​orf](https://github.com/orf) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3389](https://github.com/charliermarsh/ruff/pull/3389) - [@​DanCardin](https://github.com/DanCardin) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3417](https://github.com/charliermarsh/ruff/pull/3417) - [@​AreamanM](https://github.com/AreamanM) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3405](https://github.com/charliermarsh/ruff/pull/3405) - [@​kyoto7250](https://github.com/kyoto7250) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3411](https://github.com/charliermarsh/ruff/pull/3411) - [@​latonis](https://github.com/latonis) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3449](https://github.com/charliermarsh/ruff/pull/3449) - [@​XuehaiPan](https://github.com/XuehaiPan) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3459](https://github.com/charliermarsh/ruff/pull/3459) - [@​CalumY](https://github.com/CalumY) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3461](https://github.com/charliermarsh/ruff/pull/3461) - [@​YDX-2147483647](https://github.com/YDX-2147483647) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3473](https://github.com/charliermarsh/ruff/pull/3473) **Full Changelog**: astral-sh/ruff@v0.0.254...v0.0.255 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/ixm-one/pytest-cmake-presets). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNjAuMCIsInVwZGF0ZWRJblZlciI6IjM0LjE2MC4wIn0=--> Signed-off-by: Renovate Bot <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [ruff](https://github.com/charliermarsh/ruff) | `==0.0.254` -> `==0.0.256` | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>charliermarsh/ruff</summary> ### [`v0.0.256`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.256) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.255...v0.0.256) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Bug Fixes - PYI011: allow `math` constants in defaults by [@​XuehaiPan](https://github.com/XuehaiPan) in [https://github.com/charliermarsh/ruff/pull/3484](https://github.com/charliermarsh/ruff/pull/3484) - Remove erroneous C4-to-C40 redirect by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3488](https://github.com/charliermarsh/ruff/pull/3488) - fix lack of `not` in error message by [@​Czaki](https://github.com/Czaki) in [https://github.com/charliermarsh/ruff/pull/3497](https://github.com/charliermarsh/ruff/pull/3497) - Ensure that redirect warnings appear exactly once per code by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3500](https://github.com/charliermarsh/ruff/pull/3500) - Allow f-strings and concatenations in os.getenv by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3516](https://github.com/charliermarsh/ruff/pull/3516) - Allow string percent formatting in os.getenv by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3518](https://github.com/charliermarsh/ruff/pull/3518) - Refine complexity rules for try-except-else-finally by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3519](https://github.com/charliermarsh/ruff/pull/3519) - Replicate inline comments when splitting single-line imports by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3521](https://github.com/charliermarsh/ruff/pull/3521) - Avoid PEP 604 isinstance errors for starred tuples by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3527](https://github.com/charliermarsh/ruff/pull/3527) - Avoid tracking as-imports separately with force-single-line by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3530](https://github.com/charliermarsh/ruff/pull/3530) - Fix PYI011 and add auto-fix by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3492](https://github.com/charliermarsh/ruff/pull/3492) - Avoid PEP 604 panic with empty tuple by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3526](https://github.com/charliermarsh/ruff/pull/3526) - Add last remaining deprecated typing imports by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3529](https://github.com/charliermarsh/ruff/pull/3529) - Avoid unused argument violations in .pyi files by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3533](https://github.com/charliermarsh/ruff/pull/3533) ##### Other Changes - Include individual path checks in --verbose logging by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3489](https://github.com/charliermarsh/ruff/pull/3489) - Allow `# ruff:` prefix for isort action comments by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3493](https://github.com/charliermarsh/ruff/pull/3493) **Full Changelog**: astral-sh/ruff@v0.0.255...v0.0.256 ### [`v0.0.255`](https://github.com/charliermarsh/ruff/releases/tag/v0.0.255) [Compare Source](https://github.com/charliermarsh/ruff/compare/v0.0.254...v0.0.255) <!-- Release notes generated using configuration in .github/release.yml at main --> #### What's Changed ##### Rules - \[`flake8-pie`] Fix PIE802 broken auto-fix with trailing comma by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3402](https://github.com/charliermarsh/ruff/pull/3402) - \[`flake8-pie`] Implement autofix for PIE810 by [@​kyoto7250](https://github.com/kyoto7250) in [https://github.com/charliermarsh/ruff/pull/3411](https://github.com/charliermarsh/ruff/pull/3411) - \[`flake8-bugbear`] Add `flake8-bugbear`'s B030 rule by [@​aacunningham](https://github.com/aacunningham) in [https://github.com/charliermarsh/ruff/pull/3400](https://github.com/charliermarsh/ruff/pull/3400) - \[`pycodestyle`] Add E231 by [@​carlosmiei](https://github.com/carlosmiei) in [https://github.com/charliermarsh/ruff/pull/3344](https://github.com/charliermarsh/ruff/pull/3344) - \[`pyupgrade`] Flag deprecated (but renamed) imports in UP035 by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3448](https://github.com/charliermarsh/ruff/pull/3448) - \[`pyupgrade`] Remap ChainMap, Counter, and OrderedDict imports to collections by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3392](https://github.com/charliermarsh/ruff/pull/3392) - \[`pylint`] C1901: compare-to-empty-string by [@​AreamanM](https://github.com/AreamanM) in [https://github.com/charliermarsh/ruff/pull/3405](https://github.com/charliermarsh/ruff/pull/3405) - \[`pylint`] Implement W1508 invalid-envvar-default by [@​latonis](https://github.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3449](https://github.com/charliermarsh/ruff/pull/3449) - \[`pylint`] Implement E1507 invalid-envvar-value by [@​latonis](https://github.com/latonis) in [https://github.com/charliermarsh/ruff/pull/3467](https://github.com/charliermarsh/ruff/pull/3467) ##### Settings - Infer `target-version` from project metadata by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3470](https://github.com/charliermarsh/ruff/pull/3470) - Implement configuration options `runtime-evaluated-decorators` and `runtime-evaluated-base-classes` for `flake8-type-checking` by [@​sasanjac](https://github.com/sasanjac) in [https://github.com/charliermarsh/ruff/pull/3292](https://github.com/charliermarsh/ruff/pull/3292) - Add Azure DevOps as a `--format` option. by [@​StefanBRas](https://github.com/StefanBRas) in [https://github.com/charliermarsh/ruff/pull/3335](https://github.com/charliermarsh/ruff/pull/3335) ##### Bug Fixes - Re-enable the T and C linter prefix selectors by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3452](https://github.com/charliermarsh/ruff/pull/3452) - Treat unary operations on constants as constant-like by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3348](https://github.com/charliermarsh/ruff/pull/3348) - Skip byte-order-mark at start of file by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3343](https://github.com/charliermarsh/ruff/pull/3343) - Don't enforce typing-import rules in .pyi files by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3362](https://github.com/charliermarsh/ruff/pull/3362) - Include entire prefix when reporting rule selector errors by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3375](https://github.com/charliermarsh/ruff/pull/3375) - Handle multi-line fixes for byte-string prefixing by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3391](https://github.com/charliermarsh/ruff/pull/3391) - Catch RET504 usages via decorators by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3395](https://github.com/charliermarsh/ruff/pull/3395) - Ignore multiply-assigned variables in RET504 by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3393](https://github.com/charliermarsh/ruff/pull/3393) - \[FIX] PYI011: recognize `Bool` / `Float` / `Complex` numbers as simple defaults by [@​XuehaiPan](https://github.com/XuehaiPan) in [https://github.com/charliermarsh/ruff/pull/3459](https://github.com/charliermarsh/ruff/pull/3459) - Respect ignores for runtime-import-in-type-checking-block (TCH004) by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3474](https://github.com/charliermarsh/ruff/pull/3474) - Avoid panicking in invalid_escape_sequence by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3338](https://github.com/charliermarsh/ruff/pull/3338) - fix: Emit a more useful error if an `extend` points at a non-existent ruff.toml file. by [@​DanCardin](https://github.com/DanCardin) in [https://github.com/charliermarsh/ruff/pull/3417](https://github.com/charliermarsh/ruff/pull/3417) - Respect `--show-fixes` with `--fix-only` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3426](https://github.com/charliermarsh/ruff/pull/3426) - When "Args" and "Parameters" are present, prefer NumPy style by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3430](https://github.com/charliermarsh/ruff/pull/3430) - Remove empty line after RUF100 auto-fix by [@​JonathanPlasse](https://github.com/JonathanPlasse) in [https://github.com/charliermarsh/ruff/pull/3414](https://github.com/charliermarsh/ruff/pull/3414) - Avoid removing un-aliased exceptions in `OSError`-aliased handlers by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3451](https://github.com/charliermarsh/ruff/pull/3451) - Use a hash to fingerprint GitLab CI output by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3456](https://github.com/charliermarsh/ruff/pull/3456) - Avoid respecting noqa directives when RUF100 is enabled by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3469](https://github.com/charliermarsh/ruff/pull/3469) - Output GitLab paths relative to `CI_PROJECT_DIR` by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3475](https://github.com/charliermarsh/ruff/pull/3475) - Implement an iterator for universal newlines by [@​charliermarsh](https://github.com/charliermarsh) in [https://github.com/charliermarsh/ruff/pull/3454](https://github.com/charliermarsh/ruff/pull/3454) #### New Contributors - [@​sasanjac](https://github.com/sasanjac) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3292](https://github.com/charliermarsh/ruff/pull/3292) - [@​aacunningham](https://github.com/aacunningham) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3380](https://github.com/charliermarsh/ruff/pull/3380) - [@​orf](https://github.com/orf) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3389](https://github.com/charliermarsh/ruff/pull/3389) - [@​DanCardin](https://github.com/DanCardin) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3417](https://github.com/charliermarsh/ruff/pull/3417) - [@​AreamanM](https://github.com/AreamanM) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3405](https://github.com/charliermarsh/ruff/pull/3405) - [@​kyoto7250](https://github.com/kyoto7250) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3411](https://github.com/charliermarsh/ruff/pull/3411) - [@​latonis](https://github.com/latonis) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3449](https://github.com/charliermarsh/ruff/pull/3449) - [@​XuehaiPan](https://github.com/XuehaiPan) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3459](https://github.com/charliermarsh/ruff/pull/3459) - [@​CalumY](https://github.com/CalumY) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3461](https://github.com/charliermarsh/ruff/pull/3461) - [@​YDX-2147483647](https://github.com/YDX-2147483647) made their first contribution in [https://github.com/charliermarsh/ruff/pull/3473](https://github.com/charliermarsh/ruff/pull/3473) **Full Changelog**: astral-sh/ruff@v0.0.254...v0.0.255 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/allenporter/flux-local). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC4xNjAuMCIsInVwZGF0ZWRJblZlciI6IjM0LjE2MC4wIn0=--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
see #2195