mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-05 18:11:06 +00:00
![]() The PR add the fix safety section for rule `RUF013` (https://github.com/astral-sh/ruff/issues/15584 ) The fix was introduced here #4831 The rule as a lot of False Negative (as it is explained in the docs of the rule). The main reason because the fix is unsafe is that it could change code generation tools behaviour, as in the example here: ```python def generate_api_docs(func): hints = get_type_hints(func) for param, hint in hints.items(): if is_optional_type(hint): print(f"Parameter '{param}' is optional") else: print(f"Parameter '{param}' is required") # Before fix def create_user(name: str, roles: list[str] = None): pass # After fix def create_user(name: str, roles: Optional[list[str]] = None): pass # Generated docs would change from "roles is required" to "roles is optional" ``` |
||
---|---|---|
.. | ||
resources | ||
src | ||
Cargo.toml |