Skip to content

Commit

Permalink
Un-pin flake8 and resolve new violations
Browse files Browse the repository at this point in the history
  • Loading branch information
cottsay committed Jun 20, 2024
1 parent 66c7832 commit 355e1e5
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
'python_requires': '>=3.6',
'extras_require': {
'test': [
'flake8 < 6',
'flake8',
'flake8-comprehensions',
'pytest',
],
Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/catkin_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,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.')
Expand Down
8 changes: 4 additions & 4 deletions src/rosdep2/gbpdistro_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"')
Expand All @@ -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))

Expand Down
6 changes: 3 additions & 3 deletions src/rosdep2/installers.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,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))
Expand Down Expand Up @@ -399,7 +399,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

Expand Down
10 changes: 5 additions & 5 deletions src/rosdep2/lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,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]
Expand All @@ -116,15 +116,15 @@ 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]
return_key = installer_key
break
else:
# data must be a dictionary, string, or list
if type(data) == dict:
if type(data) is dict:
# check for
# hardy:
# apt:
Expand All @@ -143,7 +143,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]
Expand Down
6 changes: 3 additions & 3 deletions src/rosdep2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,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

Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/platforms/osx.py
Original file line number Diff line number Diff line change
Expand Up @@ -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', []))

Expand Down
2 changes: 1 addition & 1 deletion src/rosdep2/rep3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions src/rosdep2/sources_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,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_
Expand Down Expand Up @@ -304,7 +304,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:
Expand Down
4 changes: 2 additions & 2 deletions test/test_rosdep_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down

0 comments on commit 355e1e5

Please sign in to comment.