From fbce4d416706c8d74b06bb92b1fbefc76ea11a22 Mon Sep 17 00:00:00 2001 From: Scott K Logan Date: Fri, 21 Jun 2024 13:06:06 -0500 Subject: [PATCH] Un-pin flake8 and resolve new violations (#975) --- setup.py | 2 +- src/rosdep2/catkin_packages.py | 2 +- src/rosdep2/gbpdistro_support.py | 8 ++++---- src/rosdep2/installers.py | 6 +++--- src/rosdep2/lookup.py | 10 +++++----- src/rosdep2/main.py | 6 +++--- src/rosdep2/platforms/osx.py | 2 +- src/rosdep2/rep3.py | 2 +- src/rosdep2/sources_list.py | 4 ++-- test/test_rosdep_source.py | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/setup.py b/setup.py index addc1bd77..db12d0f69 100644 --- a/setup.py +++ b/setup.py @@ -16,7 +16,7 @@ 'python_requires': '>=3.6', 'extras_require': { 'test': [ - 'flake8 < 6', + 'flake8', 'flake8-comprehensions', 'pytest', ], diff --git a/src/rosdep2/catkin_packages.py b/src/rosdep2/catkin_packages.py index 8dc1342b8..e232d2ee2 100644 --- a/src/rosdep2/catkin_packages.py +++ b/src/rosdep2/catkin_packages.py @@ -31,7 +31,7 @@ def find_catkin_packages_in(path, verbose=False): print('found in cache.', file=sys.stderr) return _catkin_packages_cache[path] packages = find_packages(path) - if type(packages) == dict and packages != {}: + if type(packages) is dict and packages != {}: package_names = [package.name for package in packages.values()] if verbose: print('found ' + str(len(packages)) + ' packages.') diff --git a/src/rosdep2/gbpdistro_support.py b/src/rosdep2/gbpdistro_support.py index 0b523c6d5..be4936147 100644 --- a/src/rosdep2/gbpdistro_support.py +++ b/src/rosdep2/gbpdistro_support.py @@ -74,9 +74,9 @@ def gbprepo_to_rosdep_data(gbpdistro_data, targets_data, url=''): # (e.g. doesn't separate gbpdistro vs. targets, nor provide # origin), but rushing this implementation a bit. try: - if not type(targets_data) == dict: + if not type(targets_data) is dict: raise InvalidData('targets data must be a dict') - if not type(gbpdistro_data) == dict: + if not type(gbpdistro_data) is dict: raise InvalidData('gbpdistro data must be a dictionary') if gbpdistro_data['type'] != 'gbp': raise InvalidData('gbpdistro must be of type "gbp"') @@ -94,11 +94,11 @@ def gbprepo_to_rosdep_data(gbpdistro_data, targets_data, url=''): rosdep_data = {} gbp_repos = gbpdistro_data['repositories'] # Ensure gbp_repos is a dict - if type(gbp_repos) != dict: + if type(gbp_repos) is not dict: raise InvalidData('invalid repo spec in gbpdistro data: ' + str(gbp_repos) + '. Invalid repositories entry, must be dict.') for rosdep_key, repo in gbp_repos.items(): - if type(repo) != dict: + if type(repo) is not dict: raise InvalidData('invalid repo spec in gbpdistro data: ' + str(repo)) diff --git a/src/rosdep2/installers.py b/src/rosdep2/installers.py index 62f267b61..20a996d06 100644 --- a/src/rosdep2/installers.py +++ b/src/rosdep2/installers.py @@ -339,13 +339,13 @@ def resolve(self, rosdep_args): See :meth:`Installer.resolve()` """ packages = None - if type(rosdep_args) == dict: + if type(rosdep_args) is dict: packages = rosdep_args.get('packages', []) if isinstance(packages, str): packages = packages.split() elif isinstance(rosdep_args, str): packages = rosdep_args.split(' ') - elif type(rosdep_args) == list: + elif type(rosdep_args) is list: packages = rosdep_args else: raise InvalidData('Invalid rosdep args: %s' % (rosdep_args)) @@ -397,7 +397,7 @@ def get_depends(self, rosdep_args): necessary if the package manager doesn't handle dependencies. """ - if self.supports_depends and type(rosdep_args) == dict: + if self.supports_depends and type(rosdep_args) is dict: return rosdep_args.get('depends', []) return [] # Default return empty list diff --git a/src/rosdep2/lookup.py b/src/rosdep2/lookup.py index 52892e265..abe7e45bf 100644 --- a/src/rosdep2/lookup.py +++ b/src/rosdep2/lookup.py @@ -100,12 +100,12 @@ def get_rule_for_platform(self, os_name, os_version, installer_keys, default_ins queried_os = os_name queried_ver = os_version - if type(data) != dict: + if type(data) is not dict: raise InvalidData('rosdep value for [%s] must be a dictionary' % (self.rosdep_key), origin=self.origin) if os_name not in data: if '*' not in data: raise ResolutionError(rosdep_key, data, queried_os, queried_ver, 'No definition of [%s] for OS [%s]' % (rosdep_key, os_name)) - elif type(data['*']) != dict: + elif type(data['*']) is not dict: raise InvalidData('rosdep value under OS wildcard for [%s] must specify a package manager' % (rosdep_key)) os_name = '*' data = data[os_name] @@ -114,7 +114,7 @@ def get_rule_for_platform(self, os_name, os_version, installer_keys, default_ins # REP 111: rosdep first interprets the key as a # PACKAGE_MANAGER. If this test fails, it will be interpreted # as an OS_VERSION_CODENAME. - if type(data) == dict: + if type(data) is dict: for installer_key in installer_keys: if installer_key in data: data = data[installer_key] @@ -122,7 +122,7 @@ def get_rule_for_platform(self, os_name, os_version, installer_keys, default_ins break else: # data must be a dictionary, string, or list - if type(data) == dict: + if type(data) is dict: # check for # hardy: # apt: @@ -141,7 +141,7 @@ def get_rule_for_platform(self, os_name, os_version, installer_keys, default_ins if os_version not in data: os_version = '*' data = data[os_version] - if type(data) == dict: + if type(data) is dict: for installer_key in installer_keys: if installer_key in data: data = data[installer_key] diff --git a/src/rosdep2/main.py b/src/rosdep2/main.py index 51f942955..2bf653515 100644 --- a/src/rosdep2/main.py +++ b/src/rosdep2/main.py @@ -63,9 +63,9 @@ from .lookup import RosdepLookup, ResolutionError, prune_catkin_packages from .meta import MetaDatabase from .rospkg_loader import DEFAULT_VIEW_KEY -from .sources_list import update_sources_list, get_sources_cache_dir,\ - download_default_sources_list, SourcesListLoader, CACHE_INDEX,\ - get_sources_list_dir, get_default_sources_list_file,\ +from .sources_list import update_sources_list, get_sources_cache_dir, \ + download_default_sources_list, SourcesListLoader, CACHE_INDEX, \ + get_sources_list_dir, get_default_sources_list_file, \ DEFAULT_SOURCES_LIST_URL from .rosdistrohelper import PreRep137Warning diff --git a/src/rosdep2/platforms/osx.py b/src/rosdep2/platforms/osx.py index e789dc9c7..f137822b9 100644 --- a/src/rosdep2/platforms/osx.py +++ b/src/rosdep2/platforms/osx.py @@ -323,7 +323,7 @@ def handle_options(options): if packages: options = [] install_flags = [] - if type(rosdep_args) == dict: + if type(rosdep_args) is dict: options = coerce_to_list(rosdep_args.get('options', [])) install_flags = coerce_to_list(rosdep_args.get('install_flags', [])) diff --git a/src/rosdep2/rep3.py b/src/rosdep2/rep3.py index 0c17a8faa..fb6c93e18 100644 --- a/src/rosdep2/rep3.py +++ b/src/rosdep2/rep3.py @@ -62,7 +62,7 @@ def download_targets_data(targets_url=None): targets_data = yaml.safe_load(text) except Exception as e: raise DownloadFailure('Failed to download target platform data for gbpdistro:\n\t%s' % (str(e))) - if type(targets_data) == list: + if type(targets_data) is list: # convert to dictionary new_targets_data = {} for t in targets_data: diff --git a/src/rosdep2/sources_list.py b/src/rosdep2/sources_list.py index 85d0bc193..fd62532cd 100644 --- a/src/rosdep2/sources_list.py +++ b/src/rosdep2/sources_list.py @@ -142,7 +142,7 @@ def __init__(self, type_, url, tags, origin=None): parsed = urlparse.urlparse(url) if not parsed.scheme or (parsed.scheme != 'file' and not parsed.netloc) or parsed.path in ('', '/'): raise ValueError('url must be a fully-specified URL with scheme, hostname, and path: %s' % (str(url))) - if not type(tags) == list: + if not type(tags) is list: raise ValueError('tags must be a list: %s' % (str(tags))) self.type = type_ @@ -302,7 +302,7 @@ def download_rosdep_data(url): text = f.read() f.close() data = yaml.safe_load(text) - if type(data) != dict: + if type(data) is not dict: raise DownloadFailure('rosdep data from [%s] is not a YAML dictionary' % (url)) return data except (URLError, httplib.HTTPException) as e: diff --git a/test/test_rosdep_source.py b/test/test_rosdep_source.py index 1c24944bd..d0a8ae18d 100644 --- a/test/test_rosdep_source.py +++ b/test/test_rosdep_source.py @@ -215,7 +215,7 @@ def test_SourceInstaller_resolve(): pass resolved = installer.resolve(dict(uri=url, md5sum=md5sum_good)) - assert type(resolved) == list + assert type(resolved) is list assert len(resolved) == 1 # test for reinstall (to check the depends in rdmanifest) dependencies = installer.get_depends(dict(uri=url, md5sum=md5sum_good)) @@ -227,7 +227,7 @@ def test_SourceInstaller_resolve(): # test again to activate caching resolved = installer.resolve(dict(uri=url, md5sum=md5sum_good)) - assert type(resolved) == list, 'Cache should also return a list' + assert type(resolved) is list, 'Cache should also return a list' assert len(resolved) == 1 resolved = resolved[0] assert resolved.install_command == rep122_install_command