Skip to content

Commit

Permalink
Fix R1729
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Mar 24, 2024
1 parent 8838799 commit 5df6f16
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

# Performance optimization
# W1203: Use % formatting in logging functions and pass the parameters as arguments
# R1729: Use a generator instead of comprehension
# W1202: Use % formatting in logging functions and pass the parameters as arguments
# W1201: Specify string format arguments as logging function parameters

Expand Down Expand Up @@ -55,7 +54,7 @@
# R0401: Cyclic import -- Seems to be platform specific

max-line-length = 120
disable = C0114, C0115, C0116, R0903, C0415, R0913, W1203, R1729, E1120, E1123, C0209, W0621,
disable = C0114, C0115, C0116, R0903, C0415, R0913, W1203, E1120, E1123, C0209, W0621,
W0614, W0401, W1202, W0718, R0914, R1725, C0411, W0237, W0702, W0613,
R0912, R0911, W0511, R0902, C0412, C0103, C0301, R0915, W1514,
E1101, W1201,
Expand Down
8 changes: 4 additions & 4 deletions pros/conductor/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_template_actions(self, template: BaseTemplate) -> TemplateAction:
if current > template:
return TemplateAction.Downgradable

if any([template > current for current in self.templates.values()]):
if any(template > current for current in self.templates.values()):
return TemplateAction.Upgradable
return TemplateAction.Installable

Expand Down Expand Up @@ -144,16 +144,16 @@ def new_user_filter(new_file: str) -> bool:
src/opcontrol.c and src/opcontrol.cpp are friends because they have the same stem
src/opcontrol.c and include/opcontrol.h are not because they are in different directories
"""
return not any([(os.path.normpath(file) in transaction.effective_state) for file in template.user_files if
os.path.splitext(file)[0] == os.path.splitext(new_file)[0]])
return not any((os.path.normpath(file) in transaction.effective_state) for file in template.user_files if
os.path.splitext(file)[0] == os.path.splitext(new_file)[0])

if force_user:
new_user_files = template.real_user_files
else:
new_user_files = filter(new_user_filter, template.real_user_files)
transaction.extend_add(new_user_files, template.location)

if any([file in transaction.effective_state for file in template.system_files]) and not force_system:
if any(file in transaction.effective_state for file in template.system_files) and not force_system:
confirm(f'Some required files for {template.identifier} already exist in the project. '
f'Overwrite the existing files?', abort=True)
transaction.extend_add(template.system_files, template.location)
Expand Down
2 changes: 1 addition & 1 deletion pros/conductor/templates/base_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def satisfies(self, query: 'BaseTemplate', kernel_version: Union[str, Version] =
# Find the intersection of the keys in the template's metadata with the keys in the query metadata
# This is what allows us to throw all arguments into the query metadata (from the CLI, e.g. those intended
# for the depot or template application hints)
if any([self.metadata[k] != query.metadata[k] for k in keys_intersection]):
if any(self.metadata[k] != query.metadata[k] for k in keys_intersection):
return False
return True

Expand Down
2 changes: 1 addition & 1 deletion pros/config/cli_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def use_build_compile_commands(self):
if self.override_use_build_compile_commands is not None:
return self.override_use_build_compile_commands
paths = [os.path.join('~', '.pros-atom'), os.path.join('~', '.pros-editor')]
return any([os.path.exists(os.path.expanduser(p)) for p in paths])
return any(os.path.exists(os.path.expanduser(p)) for p in paths)

def get_upgrade_manifest(self, force: bool = False) -> Optional['UpgradeManifestV1']:
from pros.upgrade.manifests.upgrade_manifest_v1 import UpgradeManifestV1 # noqa: F811
Expand Down
4 changes: 2 additions & 2 deletions pros/serial/devices/vex/stm32_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def erase_memory(self, page_numbers: List[int]):
if not self.commands[6] == 0x43:
raise VEXCommError('Standard erase not supported on this device (only extended erase)')
assert 0 < len(page_numbers) <= 255
assert all([0 <= p <= 255 for p in page_numbers])
assert all(0 <= p <= 255 for p in page_numbers)
self._txrx_command(0x43)
self._txrx_command(bytes([len(page_numbers) - 1, *page_numbers]))

Expand All @@ -158,7 +158,7 @@ def extended_erase(self, page_numbers: List[int]):
if not self.commands[6] == 0x44:
raise IOError('Extended erase not supported on this device (only standard erase)')
assert 0 < len(page_numbers) < 0xfff0
assert all([0 <= p <= 0xffff for p in page_numbers])
assert all(0 <= p <= 0xffff for p in page_numbers)
self._txrx_command(0x44)
self._txrx_command(bytes([len(page_numbers) - 1, *struct.pack(f'>{len(page_numbers)}H', *page_numbers)]))

Expand Down
6 changes: 3 additions & 3 deletions pros/serial/devices/vex/v5_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def filter_vex_ports(p):
p.name is not None and ('VEX' in p.name or 'V5' in p.name)

def filter_v5_ports(p, locations, names):
return (p.location is not None and any([p.location.endswith(l) for l in locations])) or \
(p.name is not None and any([n in p.name for n in names])) or \
(p.description is not None and any([n in p.description for n in names]))
return (p.location is not None and any(p.location.endswith(l) for l in locations)) or \
(p.name is not None and any(n in p.name for n in names)) or \
(p.description is not None and any(n in p.description for n in names))

def filter_v5_ports_mac(p, device):
return (p.device is not None and p.device.endswith(device))
Expand Down

0 comments on commit 5df6f16

Please sign in to comment.