Skip to content

Commit

Permalink
Fix R1735
Browse files Browse the repository at this point in the history
  • Loading branch information
mayankpatibandla committed Mar 19, 2024
1 parent 54eed9f commit e174cb4
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 51 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# 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
# R1735: Use literal syntax instead of function calls to create dict
# W1201: Specify string format arguments as logging function parameters

# Fixed by auto formatter
Expand Down Expand Up @@ -60,7 +59,7 @@

max-line-length = 120
disable = C0114, C0115, C0116, R0903, C0415, R0913, W1203, R1729, E1120, E1123, C0209, R1710, W0621,
W0614, W0401, W1202, W0718, R0914, R1725, R1735, C0411, W0237, W0702, W0223, W0613,
W0614, W0401, W1202, W0718, R0914, R1725, C0411, W0237, W0702, W0223, W0613,
R0912, R0911, W0511, R0902, C0412, C0103, C0301, R0915, W1514,
E1101, W1201,
E0401, W0212, R0904, W0101,
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 @@ -103,7 +103,7 @@ def type_cast_value(self, ctx, value):
class PROSGroup(PROSFormatted, click.Group):
def __init__(self, *args, **kwargs):
super(PROSGroup, self).__init__(*args, **kwargs)
self.cmd_dict = dict()
self.cmd_dict = {}

def command(self, *args, aliases=None, **kwargs):
aliases = aliases or []
Expand Down
2 changes: 1 addition & 1 deletion pros/cli/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def upload(path: Optional[str], project: Optional[c.Project], port: str, **kwarg
kwargs['remote_name'] = project.name

# apply upload_options as a template
options = dict(**project.upload_options)
options = {**project.upload_options}
if 'port' in options and port is None:
port = options.get('port', None)
if 'slot' in options and kwargs.get('slot', None) is None:
Expand Down
2 changes: 1 addition & 1 deletion pros/common/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def prompt_to_send(event: Dict[str, Any], hint: Optional[Dict[str, Any]]) -> Opt
return

if not event['tags']:
event['tags'] = dict()
event['tags'] = {}

extra_text = ''
if 'message' in event:
Expand Down
24 changes: 12 additions & 12 deletions pros/common/ui/interactive/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ def __getstate__(self):
"""
Returns the dictionary representation of this Application
"""
return dict(
etype=Application.get_hierarchy(self.__class__),
elements=[e.__getstate__() for e in self.build()],
uuid=self.uuid
)
return {
"etype": Application.get_hierarchy(self.__class__),
"elements": [e.__getstate__() for e in self.build()],
"uuid": self.uuid
}


class Modal(Application[P], Generic[P]):
Expand Down Expand Up @@ -134,15 +134,15 @@ def __getstate__(self):
extra_state = {}
if self.description is not None:
extra_state['description'] = self.description
return dict(
return {
**super(Modal, self).__getstate__(),
**extra_state,
title=self.title,
will_abort=self.will_abort,
confirm_button=self.confirm_button,
cancel_button=self.cancel_button,
can_confirm=self.can_confirm
)
"title": self.title,
"will_abort": self.will_abort,
"confirm_button": self.confirm_button,
"cancel_button": self.cancel_button,
"can_confirm": self.can_confirm
}

def _confirm(self, *args, **kwargs):
"""
Expand Down
8 changes: 4 additions & 4 deletions pros/common/ui/interactive/components/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ def on_clicked(self, *handlers: Callable, **kwargs):
return self.on('clicked', *handlers, **kwargs)

def __getstate__(self) -> dict:
return dict(
return {
**super(Button, self).__getstate__(),
text=self.text,
uuid=self.uuid
)
"text": self.text,
"uuid": self.uuid
}
20 changes: 10 additions & 10 deletions pros/common/ui/interactive/components/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ def get_hierarchy(cls, base: type) -> Optional[List[str]]:
return None

def __getstate__(self) -> Dict:
return dict(
etype=Component.get_hierarchy(self.__class__)
)
return {
"etype": Component.get_hierarchy(self.__class__)
}


P = TypeVar('P', bound=Parameter)
Expand All @@ -52,12 +52,12 @@ def __getstate__(self):
reason = self.parameter.is_valid_reason()
if reason:
extra_state['valid_reason'] = self.parameter.is_valid_reason()
return dict(
return {
**super(ParameterizedComponent, self).__getstate__(),
**extra_state,
value=self.parameter.value,
uuid=self.parameter.uuid,
)
"value": self.parameter.value,
"uuid": self.parameter.uuid,
}


class BasicParameterizedComponent(ParameterizedComponent[P], Generic[P]):
Expand All @@ -70,7 +70,7 @@ def __init__(self, label: AnyStr, parameter: P):
self.label = label

def __getstate__(self):
return dict(
return {
**super(BasicParameterizedComponent, self).__getstate__(),
text=self.label,
)
"text": self.label,
}
6 changes: 3 additions & 3 deletions pros/common/ui/interactive/components/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __getstate__(self):
extra_state['title'] = self.title
if self.description is not None:
extra_state['description'] = self.description
return dict(
return {
**super(Container, self).__getstate__(),
**extra_state,
elements=[e.__getstate__() for e in self.elements]
)
"elements": [e.__getstate__() for e in self.elements]
}
4 changes: 2 additions & 2 deletions pros/common/ui/interactive/components/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def __getstate__(self) -> dict:
extra_state = {}
if self.placeholder is not None:
extra_state['placeholder'] = self.placeholder
return dict(
return {
**super(InputBox, self).__getstate__(),
**extra_state,
)
}


class FileSelector(InputBox[P], Generic[P]):
Expand Down
6 changes: 3 additions & 3 deletions pros/common/ui/interactive/components/input_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

class DropDownBox(BasicParameterizedComponent[OptionParameter]):
def __getstate__(self):
return dict(
return {
**super(DropDownBox, self).__getstate__(),
options=self.parameter.options
)
"options": self.parameter.options
}


class ButtonGroup(DropDownBox):
Expand Down
6 changes: 3 additions & 3 deletions pros/common/ui/interactive/components/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ def __init__(self, text: AnyStr):
self.text = text

def __getstate__(self):
return dict(
return {
**super(Label, self).__getstate__(),
text=self.text
)
"text": self.text
}


class VerbatimLabel(Label):
Expand Down
2 changes: 1 addition & 1 deletion pros/common/ui/interactive/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from pros.common import logger

_uuid_table = dict() # type: Dict[str, Observable]
_uuid_table = {} # type: Dict[str, Observable]


class Observable(observable.Observable):
Expand Down
10 changes: 5 additions & 5 deletions pros/conductor/interactive/UpdateProjectModal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ def is_processing(self, value: bool):

def _generate_transaction(self) -> ProjectTransaction:
transaction = ProjectTransaction(self.project, self.conductor)
apply_kwargs = dict(
force_apply=self.force_apply_parameter.value
)
apply_kwargs = {
"force_apply": self.force_apply_parameter.value
}
if self.name.value != self.project.name:
transaction.change_name(self.name.value)
if self.project.template_is_applicable(self.current_kernel.value, **apply_kwargs):
Expand Down Expand Up @@ -130,9 +130,9 @@ def build(self) -> Generator[components.Component, None, None]:
assert self.project is not None
yield components.Label(f'Modify your {self.project.target} project.')
yield components.InputBox('Project Name', self.name)
yield TemplateListingComponent(self.current_kernel, editable=dict(version=True), removable=False)
yield TemplateListingComponent(self.current_kernel, editable={"version": True}, removable=False)
yield components.Container(
*(TemplateListingComponent(t, editable=dict(version=True), removable=True) for t in
*(TemplateListingComponent(t, editable={"version": True}, removable=True) for t in
self.current_templates),
*(TemplateListingComponent(t, editable=True, removable=True) for t in self.new_templates),
self.add_template_button,
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 @@ -65,7 +65,7 @@ def __hash__(self):

def as_query(self, version='>0', metadata=False, **kwargs):
if isinstance(metadata, bool) and not metadata:
metadata = dict()
metadata = {}
return BaseTemplate(orig=self, version=version, metadata=metadata, **kwargs)

@property
Expand Down
4 changes: 2 additions & 2 deletions pros/serial/devices/vex/v5_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def ft_write(self, addr: int, payload: Union[Iterable, bytes, bytearray, str]):
def ft_read(self, addr: int, n_bytes: int) -> bytearray:
logger(__name__).debug('Sending ext 0x14 command')
actual_n_bytes = n_bytes + (0 if n_bytes % 4 == 0 else 4 - n_bytes % 4)
ui.logger(__name__).debug(dict(actual_n_bytes=actual_n_bytes, addr=addr))
ui.logger(__name__).debug({"actual_n_bytes": actual_n_bytes, "addr": addr})
tx_payload = struct.pack("<IH", addr, actual_n_bytes)
rx_fmt = "<I{}s".format(actual_n_bytes)
ret = self._txrx_ext_struct(0x14, tx_payload, rx_fmt, check_ack=False)[1][:n_bytes]
Expand Down Expand Up @@ -773,7 +773,7 @@ def get_file_metadata_by_name(self, file_name: str, vid: int_str = 1, options: i
logger(__name__).debug('Sending ext 0x19 command')
if isinstance(vid, str):
vid = self.vid_map[vid.lower()]
ui.logger(__name__).debug(f'Options: {dict(vid=vid, file_name=file_name)}')
ui.logger(__name__).debug(f"Options: {{'vid': {vid}, 'file_name': {file_name}}}")
tx_payload = struct.pack("<2B24s", vid, options, file_name.encode(encoding='ascii'))
rx = self._txrx_ext_struct(0x19, tx_payload, "<B3L4sLL24s")
rx = dict(zip(['linked_vid', 'size', 'addr', 'crc', 'type', 'timestamp', 'version', 'linked_filename'], rx))
Expand Down

0 comments on commit e174cb4

Please sign in to comment.