Skip to content

Commit

Permalink
Fix flake8-bugbear warning
Browse files Browse the repository at this point in the history
B009 Do not call `getattr` with a constant attribute value.
     It is not any safer than normal property access.

Fix a MyPy typing issue, instead of using a Python hack to
silence the PyPy error:
	error: Incompatible types in assignment (expression
	       has type "Optional[str]", variable has type
	       "str")  [assignment]
  • Loading branch information
DimitriPapadopoulos committed Jan 5, 2024
1 parent 0915fee commit 57cdfe6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _glibc_version_string_confstr() -> Optional[str]:
# https://github.com/python/cpython/blob/fcf1d003bf4f0100c/Lib/platform.py#L175-L183
try:
# Should be a string like "glibc 2.17".
version_string: str = getattr(os, "confstr")("CS_GNU_LIBC_VERSION")
version_string: Optional[str] = os.confstr("CS_GNU_LIBC_VERSION")
assert version_string is not None
_, version = version_string.rsplit()
except (AssertionError, AttributeError, OSError, ValueError):
Expand Down

0 comments on commit 57cdfe6

Please sign in to comment.