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.

The rationale is to hint this is a hack to work around this
MyPy error, probably related to the inavailability of
os.confstr() outside Unix:
	error: Incompatible types in assignment (expression
	       has type "Optional[str]", variable has type
	       "str")  [assignment]
  • Loading branch information
DimitriPapadopoulos committed Jan 4, 2024
1 parent 0915fee commit 5a0316f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/packaging/_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ 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: str = getattr(os, "confstr")(
"CS_GNU_LIBC_VERSION"
) # noqa: B009
assert version_string is not None
_, version = version_string.rsplit()
except (AssertionError, AttributeError, OSError, ValueError):
Expand Down

0 comments on commit 5a0316f

Please sign in to comment.