mirror of https://github.com/astral-sh/ruff
37 lines
632 B
Python
37 lines
632 B
Python
def foo(shell):
|
|
pass
|
|
|
|
|
|
foo(shell=True)
|
|
|
|
foo(shell={**{}})
|
|
foo(shell={**{**{}}})
|
|
|
|
# Truthy non-bool values for `shell`
|
|
foo(shell=(i for i in ()))
|
|
foo(shell=lambda: 0)
|
|
|
|
# f-strings guaranteed non-empty
|
|
foo(shell=f"{b''}")
|
|
x = 1
|
|
foo(shell=f"{x=}")
|
|
|
|
# Additional truthiness cases for generator, lambda, and f-strings
|
|
foo(shell=(i for i in ()))
|
|
foo(shell=lambda: 0)
|
|
foo(shell=f"{b''}")
|
|
x = 1
|
|
foo(shell=f"{x=}")
|
|
print(bool(dict(shell=f"{f""!s}")["shell"]))
|
|
|
|
# Unknown truthiness
|
|
print(bool(dict(shell=f"{"x":.0}")["shell"]))
|
|
|
|
|
|
class C:
|
|
def __gt__(self, other):
|
|
return ""
|
|
|
|
|
|
print(bool(dict(shell=f"{C() > C()}")["shell"]))
|