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.

This was probably a hack to work around this MyPy error:
	error: Incompatible types in assignment (expression
	       has type "Optional[str]", variable has type
	       "str")  [assignment]
nstead, fix the error by using the proper type.
  • Loading branch information
DimitriPapadopoulos committed Jan 5, 2024
1 parent 0915fee commit 7093d37
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[int] = 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 7093d37

Please sign in to comment.