Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def opener(path, flags):
def foo(y: int):
open(y)


# https://github.com/astral-sh/ruff/issues/17691
def f() -> int:
return 1
Expand All @@ -68,3 +69,16 @@ def f() -> int:
def bytes_str_func() -> bytes:
return b"foo"
open(bytes_str_func())

# https://github.com/astral-sh/ruff/issues/17693
os.stat(1)
os.stat(x)


def func() -> int:
return 2
os.stat(func())


def bar(x: int):
os.stat(x)
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,16 @@ pub(crate) fn replaceable_by_pathlib(checker: &Checker, call: &ExprCall) {
// PTH114
["os", "path", "islink"] => OsPathIslink.into(),
// PTH116
["os", "stat"] => OsStat.into(),
["os", "stat"] => {
if call
.arguments
.find_positional(0)
.is_some_and(|expr| is_file_descriptor(expr, checker.semantic()))
{
return;
}
OsStat.into()
}
// PTH117
["os", "path", "isabs"] => OsPathIsabs.into(),
// PTH118
Expand Down
Loading