Skip to content

Commit

Permalink
Fix R1710
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Mar 24, 2024
1 parent a3be556 commit 8838799
Show file tree
Hide file tree
Showing 14 changed files with 31 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
# E1120: No value for argument in function call
# E1123: Unexpected argument in function call
# C0209: Consider using an f-string
# R1710: Either all return statements in a function should return an expression, or none of them should
# W0621: Redefining name from outer scope
# W0614: Unused import from wildcard import
# W0401: Wildcard import
Expand Down Expand Up @@ -56,7 +55,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, R1710, W0621,
disable = C0114, C0115, C0116, R0903, C0415, R0913, W1203, R1729, 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
2 changes: 1 addition & 1 deletion pros/cli/click_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(self, *args, hidden: bool = False, group: str = None, **kwargs):

def get_help_record(self, ctx):
if hasattr(self, 'hidden') and self.hidden:
return
return None
return super().get_help_record(ctx)

class PROSDeprecated(click.Option):
Expand Down
2 changes: 1 addition & 1 deletion pros/cli/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def callback(ctx: click.Context, param: click.core.Parameter, value: Any):
def logfile_option(f: Union[click.Command, Callable]):
def callback(ctx: click.Context, param: click.core.Parameter, value: Any):
if value is None or value[0] is None:
return None
return
ctx.ensure_object(dict)
level = None
if isinstance(value[1], str):
Expand Down
1 change: 1 addition & 0 deletions pros/cli/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def fetch(query: c.BaseTemplate):
# whether the arguments are for the template or for the depot, so they share them
logger(__name__).debug(f'Additional depot and template args: {query.metadata}')
c.Conductor().fetch_template(depot, template, **query.metadata)
return 0


@conductor.command(context_settings={'ignore_unknown_options': True})
Expand Down
2 changes: 1 addition & 1 deletion pros/cli/conductor_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def purge_template(query: c.BaseTemplate, force):
beta_templates = cond.resolve_templates(query, allow_online=False, beta=True)
if len(templates) == 0:
click.echo('No matching templates were found matching the spec.')
return 0
return
t_list = [t.identifier for t in templates] + [t.identifier for t in beta_templates]
click.echo(f'The following template(s) will be removed {t_list}')
if len(templates) > 1 and not force:
Expand Down
2 changes: 1 addition & 1 deletion pros/cli/misc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def upgrade(force_check, no_install):
with ui.Notification():
ui.echo('The "pros upgrade" command is currently non-functioning. Did you mean to run "pros c upgrade"?', color='yellow')

return # Dead code below
return None # Dead code below

analytics.send("upgrade")
from pros.upgrade import UpgradeManager
Expand Down
1 change: 1 addition & 0 deletions pros/cli/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def terminal(port: str, backend: str, **kwargs):
else:
device = devices.vex.V5UserDevice(ser)
term = Terminal(device, request_banner=kwargs.pop('request_banner', True))
return 0

class TerminalOutput:
def __init__(self, file):
Expand Down
13 changes: 12 additions & 1 deletion pros/cli/v5_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def status(port: str):
print('CPU0 F/W version:', device.status['cpu0_version'])
print('CPU1 SDK version:', device.status['cpu1_version'])
print('System ID: 0x{:x}'.format(device.status['system_id']))
return 0


@v5.command('ls-files')
Expand All @@ -59,6 +60,7 @@ def ls_files(port: str, vid: int, options: int):
c = device.get_dir_count(vid=vid, options=options)
for i in range(0, c):
print(device.get_file_metadata_by_idx(i))
return 0


@v5.command(hidden=True)
Expand All @@ -83,6 +85,7 @@ def read_file(file_name: str, port: str, vid: int, source: str):
device = V5Device(ser)
device.read_file(file=click.get_binary_stream('stdout'), remote_file=file_name,
vid=vid, target=source)
return 0


@v5.command(hidden=True)
Expand All @@ -108,6 +111,7 @@ def write_file(file, port: str, remote_file: str, **kwargs):
ser = DirectPort(port)
device = V5Device(ser)
device.write_file(file=file, remote_file=remote_file or os.path.basename(file.name), **kwargs)
return 0


@v5.command('rm-file')
Expand All @@ -131,6 +135,7 @@ def rm_file(file_name: str, port: str, vid: int, erase_all: bool):
ser = DirectPort(port)
device = V5Device(ser)
device.erase_file(file_name, vid=vid, erase_all=erase_all)
return 0


@v5.command('cat-metadata')
Expand All @@ -152,6 +157,7 @@ def cat_metadata(file_name: str, port: str, vid: int):
ser = DirectPort(port)
device = V5Device(ser)
print(device.get_file_metadata_by_name(file_name, vid=vid))
return 0

@v5.command('rm-program')
@click.argument('slot')
Expand All @@ -173,6 +179,7 @@ def rm_program(slot: int, port: str, vid: int):
device = V5Device(ser)
device.erase_file(f'{base_name}.ini', vid=vid)
device.erase_file(f'{base_name}.bin', vid=vid)
return 0

@v5.command('rm-all')
@click.argument('port', required=False, default=None)
Expand All @@ -197,6 +204,7 @@ def rm_all(port: str, vid: int):
files.append(device.get_file_metadata_by_idx(i)['filename'])
for file in files:
device.erase_file(file, vid=vid)
return 0


@v5.command(short_help='Run a V5 Program')
Expand All @@ -221,6 +229,7 @@ def run(slot: str, port: str):
ser = DirectPort(port)
device = V5Device(ser)
device.execute_program_file(file, run=True)
return 0


@v5.command(short_help='Stop a V5 Program')
Expand All @@ -240,6 +249,7 @@ def stop(port: str):
ser = DirectPort(port)
device = V5Device(ser)
device.execute_program_file('', run=False)
return 0


@v5.command(short_help='Take a screen capture of the display')
Expand Down Expand Up @@ -275,7 +285,7 @@ def capture(file_name: str, port: str, force: bool = False):
if file_name == '-':
# Send the data to stdout to allow for piping
print(i_data, end='')
return
return 0

if not file_name.endswith('.png'):
file_name += '.png'
Expand All @@ -290,6 +300,7 @@ def capture(file_name: str, port: str, force: bool = False):
w.write(file_, i_data)

print(f'Saved screen capture to {file_name}')
return 0

@v5.command('set-variable', aliases=['sv', 'set', 'set_variable'], short_help='Set a kernel variable on a connected V5 device')
@click.argument('variable', type=click.Choice(['teamnumber', 'robotname']), required=True)
Expand Down
9 changes: 5 additions & 4 deletions pros/common/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ def prompt_to_send(event: Dict[str, Any], hint: Optional[Dict[str, Any]]) -> Opt
"""
with ui.Notification():
if cli_config is None or (cli_config.offer_sentry is not None and not cli_config.offer_sentry):
return
return None
if force_prompt_off:
ui.logger(__name__).debug('Sentry prompt was forced off through click option')
return
return None
if 'extra' in event and not event['extra'].get('sentry', True):
ui.logger(__name__).debug('Not sending candidate event because event was tagged with extra.sentry = False')
return
return None
if 'exc_info' in hint and (not getattr(hint['exc_info'][1], 'sentry', True) or
any(isinstance(hint['exc_info'][1], t) for t in SUPPRESSED_EXCEPTIONS)):
ui.logger(__name__).debug('Not sending candidate event because exception was tagged with sentry = False')
return
return None

if not event['tags']:
event['tags'] = {}
Expand All @@ -57,6 +57,7 @@ def prompt_to_send(event: Dict[str, Any], hint: Optional[Dict[str, Any]]) -> Opt
ui.echo(f'Want to get updates? Visit https://pros.cs.purdue.edu/report.html?event={event["event_id"]}')
return event
ui.echo('Not sending bug report.')
return None


def add_context(obj: object, override_handlers: bool = True, key: str = None) -> None:
Expand Down
2 changes: 2 additions & 0 deletions pros/common/ui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def echo(text: Any, err: bool = False, nl: bool = True, notify_value: int = None
return _machine_notify('echo', {'text': str(text) + ('\n' if nl else '')}, notify_value)
else:
return click.echo(str(text), nl=nl, err=err, color=color)
return None


def confirm(text: str, default: bool = False, abort: bool = False, prompt_suffix: bool = ': ',
Expand Down Expand Up @@ -61,6 +62,7 @@ def prompt(text, default=None, hide_input=False,
return click.prompt(text, default=default, hide_input=hide_input, confirmation_prompt=confirmation_prompt,
type=value_type, value_proc=value_proc, prompt_suffix=prompt_suffix, show_default=show_default,
err=err)
return None


def progressbar(iterable: Iterable = None, length: int = None, label: str = None, show_eta: bool = True,
Expand Down
1 change: 1 addition & 0 deletions pros/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def _wrap(*args, **kwargs):
return func(*args, **kwargs)
except BaseException as e:
logger(__name__).exception(e)
return None

return _wrap

Expand Down
3 changes: 2 additions & 1 deletion pros/conductor/conductor.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,8 @@ def apply_template(self, project: Project, identifier: Union[str, BaseTemplate],
kwargs['version'] = '>=0'
kwargs['early_access'] = True
# Recall the function with early access enabled
return self.apply_template(project, identifier, **kwargs)
self.apply_template(project, identifier, **kwargs)
return

self.save()
if not isinstance(template, LocalTemplate):
Expand Down
1 change: 1 addition & 0 deletions pros/conductor/project/ProjectTransaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ def describe(self, conductor: c.Conductor, project: c.Project):
if self.suppress_already_installed:
return f'{self.template.identifier} will not be re-applied.'
return f'{self.template.identifier} cannot be applied to project because it is already installed.'
return None

def can_execute(self, conductor: c.Conductor, project: c.Project) -> bool:
action = project.get_template_actions(conductor.resolve_template(self.template))
Expand Down
2 changes: 1 addition & 1 deletion pros/serial/terminal/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def getkey(self):
[], None)
if self.pipe_r in ready:
os.read(self.pipe_r, 1)
return
return None
c = self.enc_stdin.read(1)
if c == chr(0x7f):
c = chr(8) # map the BS key (which yields DEL) to backspace
Expand Down

0 comments on commit 8838799

Please sign in to comment.