Skip to content

Commit c6a00db

Browse files
committed
Avoid unnecessary getattr/setattr
1 parent e39c267 commit c6a00db

2 files changed

Lines changed: 4 additions & 6 deletions

File tree

‎pyproject.toml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ ignore = [
8484
"SIM905", # Consider using a list literal instead of `str.split`
8585
"UP030", # Use implicit references for positional format fields
8686
"UP006", # Use `list` instead of `List` for type annotation
87-
"B009", # Do not call `getattr` with a constant attribute value. It is not any safer than normal property access.
88-
"B010", # Do not call `setattr` with a constant attribute value. It is not any safer than normal property access.
8987
"RUF059", # Unpacked variable `matches` is never used
9088
"SIM102", # Use a single `if` statement instead of nested `if` statements
9189
"FA100", # Add `from __future__ import annotations` to simplify `typing.Optional`

‎tests/test_commandline.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,8 @@ def test_max_n(run):
642642
def test_quiet_is_quiet():
643643
captured_standard_output = StringIO()
644644
captured_standard_error = StringIO()
645-
setattr(captured_standard_output, "buffer", BytesIO())
646-
setattr(captured_standard_error, "buffer", BytesIO())
645+
captured_standard_output.buffer = BytesIO()
646+
captured_standard_error.buffer = BytesIO()
647647
old_stdout = sys.stdout
648648
old_stderr = sys.stderr
649649
try:
@@ -655,8 +655,8 @@ def test_quiet_is_quiet():
655655
sys.stderr = old_stderr
656656
assert captured_standard_output.getvalue() == ""
657657
assert captured_standard_error.getvalue() == ""
658-
assert getattr(captured_standard_output, "buffer").getvalue() == b""
659-
assert getattr(captured_standard_output, "buffer").getvalue() == b""
658+
assert captured_standard_output.buffer.getvalue() == b""
659+
assert captured_standard_output.buffer.getvalue() == b""
660660

661661

662662
def test_x_brace_notation():

0 commit comments

Comments
 (0)