From 1a5c7747b30bea6a016d8f8c7c32848c6daedd50 Mon Sep 17 00:00:00 2001 From: Christopher Goes Date: Wed, 11 May 2022 22:14:30 -0600 Subject: [PATCH] lint fixes --- getmac/getmac.py | 14 ++++---------- tests/test_samples.py | 21 ++++++++++++--------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/getmac/getmac.py b/getmac/getmac.py index 078849e..8e44ff5 100644 --- a/getmac/getmac.py +++ b/getmac/getmac.py @@ -1139,8 +1139,7 @@ def initialize_method_cache(method_type): # type: (str) -> bool # Filter methods by the platform we're running on platform_methods = [ - method for method in METHODS - if PLATFORM in method.platforms + method for method in METHODS if PLATFORM in method.platforms ] # type: List[Type[Method]] if not platform_methods: # If there isn't a method for the current platform, @@ -1150,10 +1149,7 @@ def initialize_method_cache(method_type): # type: (str) -> bool "Falling back to platform 'other'", PLATFORM, ) - platform_methods = [ - method for method in METHODS - if "other" in method.platforms - ] + platform_methods = [method for method in METHODS if "other" in method.platforms] if DEBUG: meth_strs = ", ".join(pm.__name__ for pm in platform_methods) # type: str log.debug("'%s' platform_methods: %s", method_type, meth_strs) @@ -1240,9 +1236,7 @@ def _attempt_method_get( ): # type: (Method, str, str) -> Optional[str] """Attempt to use methods, and if they fail, fallback to the next method in the cache.""" if not METHOD_CACHE[method_type] and not FALLBACK_CACHE[method_type]: - log.critical( - "No usable methods found for MAC type '%s'", method_type - ) + log.critical("No usable methods found for MAC type '%s'", method_type) return None result = None @@ -1301,7 +1295,7 @@ def get_by_method(method_type, arg=""): # type: (str, str) -> Optional[str] if not method: # Initialize the cache if it hasn't been already initialize_method_cache(method_type) - method = METHOD_CACHE[method_type] # type: Optional[Method] + method = METHOD_CACHE[method_type] if not method: log.error( "Initialization failed for method %s. It may not be supported " diff --git a/tests/test_samples.py b/tests/test_samples.py index 8fc4484..df8ef23 100644 --- a/tests/test_samples.py +++ b/tests/test_samples.py @@ -211,15 +211,18 @@ def test_wsl_ifconfig(benchmark, mocker, get_sample): assert "00:15:5d:83:d9:0a" == benchmark(getmac.IfconfigLinux().get, arg="eth8") -@pytest.mark.parametrize(("expected_mac", "iface_arg"), [ - ("b4:2e:99:36:1e:33", "eth0"), - ("b4:2e:99:35:1e:86", "eth3"), - ("00:15:5d:83:d9:0a", "eth8"), - (None, "lo"), - ("00:ff:36:20:68:56", "eth15"), - (None, "eth16"), - (None, "eth"), -]) +@pytest.mark.parametrize( + ("expected_mac", "iface_arg"), + [ + ("b4:2e:99:36:1e:33", "eth0"), + ("b4:2e:99:35:1e:86", "eth3"), + ("00:15:5d:83:d9:0a", "eth8"), + (None, "lo"), + ("00:ff:36:20:68:56", "eth15"), + (None, "eth16"), + (None, "eth"), + ], +) def test_wsl_ip_link_iface(benchmark, mocker, get_sample, expected_mac, iface_arg): mocker.patch("getmac.getmac.IpLinkIface._tested_arg", True) mocker.patch("getmac.getmac.IpLinkIface._iface_arg", False)