From 1134e85972afb77f410eed90c4a86f18ab568b2f Mon Sep 17 00:00:00 2001 From: chiri Date: Tue, 16 Dec 2025 20:19:43 +0300 Subject: [PATCH] fix --- ...ake8_use_pathlib__tests__full_name.py.snap | 56 ++--- ..._pathlib__tests__preview_full_name.py.snap | 202 +++++++++--------- 2 files changed, 129 insertions(+), 129 deletions(-) diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap index 1b3a53b535..dfc79473c0 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__full_name.py.snap @@ -568,63 +568,63 @@ PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` 139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) | ^^^^^^^^^^^^^^^^ 140 | -141 | import sys +141 | # See: https://github.com/astral-sh/ruff/issues/21794 | help: Replace with `Path(...).samefile()` PTH104 `os.rename()` should be replaced by `Path.rename()` - --> full_name.py:143:4 + --> full_name.py:144:4 | -141 | import sys -142 | -143 | if os.rename("pth1.py", "pth1.py.bak"): +142 | import sys +143 | +144 | if os.rename("pth1.py", "pth1.py.bak"): | ^^^^^^^^^ -144 | print("rename: truthy") -145 | else: +145 | print("rename: truthy") +146 | else: | help: Replace with `Path(...).rename(...)` PTH105 `os.replace()` should be replaced by `Path.replace()` - --> full_name.py:148:4 + --> full_name.py:149:4 | -146 | print("rename: falsey") -147 | -148 | if os.replace("pth1.py.bak", "pth1.py"): +147 | print("rename: falsey") +148 | +149 | if os.replace("pth1.py.bak", "pth1.py"): | ^^^^^^^^^^ -149 | print("replace: truthy") -150 | else: +150 | print("replace: truthy") +151 | else: | help: Replace with `Path(...).replace(...)` PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - --> full_name.py:154:14 + --> full_name.py:155:14 | -153 | try: -154 | for _ in os.getcwd(): +154 | try: +155 | for _ in os.getcwd(): | ^^^^^^^^^ -155 | print("getcwd: iterable") -156 | break +156 | print("getcwd: iterable") +157 | break | help: Replace with `Path.cwd()` PTH109 `os.getcwd()` should be replaced by `Path.cwd()` - --> full_name.py:161:14 + --> full_name.py:162:14 | -160 | try: -161 | for _ in os.getcwdb(): +161 | try: +162 | for _ in os.getcwdb(): | ^^^^^^^^^^ -162 | print("getcwdb: iterable") -163 | break +163 | print("getcwdb: iterable") +164 | break | help: Replace with `Path.cwd()` PTH115 `os.readlink()` should be replaced by `Path.readlink()` - --> full_name.py:168:14 + --> full_name.py:169:14 | -167 | try: -168 | for _ in os.readlink(sys.executable): +168 | try: +169 | for _ in os.readlink(sys.executable): | ^^^^^^^^^^^ -169 | print("readlink: iterable") -170 | break +170 | print("readlink: iterable") +171 | break | help: Replace with `Path(...).readlink()` diff --git a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap index 63f12a1d0b..c8ee502fe7 100644 --- a/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap +++ b/crates/ruff_linter/src/rules/flake8_use_pathlib/snapshots/ruff_linter__rules__flake8_use_pathlib__tests__preview_full_name.py.snap @@ -1038,141 +1038,141 @@ PTH121 `os.path.samefile()` should be replaced by `Path.samefile()` 139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) | ^^^^^^^^^^^^^^^^ 140 | -141 | import sys +141 | # See: https://github.com/astral-sh/ruff/issues/21794 | help: Replace with `Path(...).samefile()` PTH104 [*] `os.rename()` should be replaced by `Path.rename()` - --> full_name.py:143:4 + --> full_name.py:144:4 | -141 | import sys -142 | -143 | if os.rename("pth1.py", "pth1.py.bak"): +142 | import sys +143 | +144 | if os.rename("pth1.py", "pth1.py.bak"): | ^^^^^^^^^ -144 | print("rename: truthy") -145 | else: - | -help: Replace with `Path(...).rename(...)` -139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) -140 | -141 | import sys -142 + import pathlib -143 | - - if os.rename("pth1.py", "pth1.py.bak"): -144 + if pathlib.Path("pth1.py").rename("pth1.py.bak"): 145 | print("rename: truthy") 146 | else: -147 | print("rename: falsey") + | +help: Replace with `Path(...).rename(...)` +140 | +141 | # See: https://github.com/astral-sh/ruff/issues/21794 +142 | import sys +143 + import pathlib +144 | + - if os.rename("pth1.py", "pth1.py.bak"): +145 + if pathlib.Path("pth1.py").rename("pth1.py.bak"): +146 | print("rename: truthy") +147 | else: +148 | print("rename: falsey") note: This is an unsafe fix and may change runtime behavior PTH105 [*] `os.replace()` should be replaced by `Path.replace()` - --> full_name.py:148:4 + --> full_name.py:149:4 | -146 | print("rename: falsey") -147 | -148 | if os.replace("pth1.py.bak", "pth1.py"): - | ^^^^^^^^^^ -149 | print("replace: truthy") -150 | else: - | -help: Replace with `Path(...).replace(...)` -139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) -140 | -141 | import sys -142 + import pathlib -143 | -144 | if os.rename("pth1.py", "pth1.py.bak"): -145 | print("rename: truthy") -146 | else: 147 | print("rename: falsey") -148 | - - if os.replace("pth1.py.bak", "pth1.py"): -149 + if pathlib.Path("pth1.py.bak").replace("pth1.py"): +148 | +149 | if os.replace("pth1.py.bak", "pth1.py"): + | ^^^^^^^^^^ 150 | print("replace: truthy") 151 | else: -152 | print("replace: falsey") + | +help: Replace with `Path(...).replace(...)` +140 | +141 | # See: https://github.com/astral-sh/ruff/issues/21794 +142 | import sys +143 + import pathlib +144 | +145 | if os.rename("pth1.py", "pth1.py.bak"): +146 | print("rename: truthy") +147 | else: +148 | print("rename: falsey") +149 | + - if os.replace("pth1.py.bak", "pth1.py"): +150 + if pathlib.Path("pth1.py.bak").replace("pth1.py"): +151 | print("replace: truthy") +152 | else: +153 | print("replace: falsey") note: This is an unsafe fix and may change runtime behavior PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` - --> full_name.py:154:14 + --> full_name.py:155:14 | -153 | try: -154 | for _ in os.getcwd(): - | ^^^^^^^^^ -155 | print("getcwd: iterable") -156 | break - | -help: Replace with `Path.cwd()` -139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) -140 | -141 | import sys -142 + import pathlib -143 | -144 | if os.rename("pth1.py", "pth1.py.bak"): -145 | print("rename: truthy") --------------------------------------------------------------------------------- -152 | print("replace: falsey") -153 | 154 | try: - - for _ in os.getcwd(): -155 + for _ in pathlib.Path.cwd(): +155 | for _ in os.getcwd(): + | ^^^^^^^^^ 156 | print("getcwd: iterable") 157 | break -158 | except TypeError as e: + | +help: Replace with `Path.cwd()` +140 | +141 | # See: https://github.com/astral-sh/ruff/issues/21794 +142 | import sys +143 + import pathlib +144 | +145 | if os.rename("pth1.py", "pth1.py.bak"): +146 | print("rename: truthy") +-------------------------------------------------------------------------------- +153 | print("replace: falsey") +154 | +155 | try: + - for _ in os.getcwd(): +156 + for _ in pathlib.Path.cwd(): +157 | print("getcwd: iterable") +158 | break +159 | except TypeError as e: note: This is an unsafe fix and may change runtime behavior PTH109 [*] `os.getcwd()` should be replaced by `Path.cwd()` - --> full_name.py:161:14 + --> full_name.py:162:14 | -160 | try: -161 | for _ in os.getcwdb(): - | ^^^^^^^^^^ -162 | print("getcwdb: iterable") -163 | break - | -help: Replace with `Path.cwd()` -139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) -140 | -141 | import sys -142 + import pathlib -143 | -144 | if os.rename("pth1.py", "pth1.py.bak"): -145 | print("rename: truthy") --------------------------------------------------------------------------------- -159 | print("getcwd: not iterable") -160 | 161 | try: - - for _ in os.getcwdb(): -162 + for _ in pathlib.Path.cwd(): +162 | for _ in os.getcwdb(): + | ^^^^^^^^^^ 163 | print("getcwdb: iterable") 164 | break -165 | except TypeError as e: + | +help: Replace with `Path.cwd()` +140 | +141 | # See: https://github.com/astral-sh/ruff/issues/21794 +142 | import sys +143 + import pathlib +144 | +145 | if os.rename("pth1.py", "pth1.py.bak"): +146 | print("rename: truthy") +-------------------------------------------------------------------------------- +160 | print("getcwd: not iterable") +161 | +162 | try: + - for _ in os.getcwdb(): +163 + for _ in pathlib.Path.cwd(): +164 | print("getcwdb: iterable") +165 | break +166 | except TypeError as e: note: This is an unsafe fix and may change runtime behavior PTH115 [*] `os.readlink()` should be replaced by `Path.readlink()` - --> full_name.py:168:14 + --> full_name.py:169:14 | -167 | try: -168 | for _ in os.readlink(sys.executable): - | ^^^^^^^^^^^ -169 | print("readlink: iterable") -170 | break - | -help: Replace with `Path(...).readlink()` -139 | os.path.samefile("pth1_file", "pth1_link", 1, *[1], **{"x": 1}, foo=1) -140 | -141 | import sys -142 + import pathlib -143 | -144 | if os.rename("pth1.py", "pth1.py.bak"): -145 | print("rename: truthy") --------------------------------------------------------------------------------- -166 | print("getcwdb: not iterable") -167 | 168 | try: - - for _ in os.readlink(sys.executable): -169 + for _ in pathlib.Path(sys.executable).readlink(): +169 | for _ in os.readlink(sys.executable): + | ^^^^^^^^^^^ 170 | print("readlink: iterable") 171 | break -172 | except TypeError as e: + | +help: Replace with `Path(...).readlink()` +140 | +141 | # See: https://github.com/astral-sh/ruff/issues/21794 +142 | import sys +143 + import pathlib +144 | +145 | if os.rename("pth1.py", "pth1.py.bak"): +146 | print("rename: truthy") +-------------------------------------------------------------------------------- +167 | print("getcwdb: not iterable") +168 | +169 | try: + - for _ in os.readlink(sys.executable): +170 + for _ in pathlib.Path(sys.executable).readlink(): +171 | print("readlink: iterable") +172 | break +173 | except TypeError as e: note: This is an unsafe fix and may change runtime behavior