Skip to content

Commit

Permalink
review fixes & shadows in linting
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhroom committed Oct 14, 2024
1 parent 4da2160 commit f514262
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ version = {attr = "rascal2.RASCAL2_VERSION"}
line-length = 120

[tool.ruff.lint]
select = ["E", "F", "UP", "B", "SIM", "I", "N", "TD003"]
select = ["E", "F", "UP", "B", "SIM", "I", "N", "TD003", "A"]
ignore = ["SIM108", "N817"]

[tool.ruff.lint.flake8-pytest-style]
Expand Down
4 changes: 2 additions & 2 deletions rascal2/core/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ class LogLevels(IntEnum):

Debug = logging.DEBUG
Info = logging.INFO
Warning = logging.WARNING
Warn = logging.WARNING
Error = logging.ERROR
Critical = logging.CRITICAL

def __str__(self):
names = {
LogLevels.Debug: "DEBUG",
LogLevels.Info: "INFO",
LogLevels.Warning: "WARNING",
LogLevels.Warn: "WARNING",
LogLevels.Error: "ERROR",
LogLevels.Critical: "CRITICAL",
}
Expand Down
24 changes: 12 additions & 12 deletions rascal2/widgets/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def get_validated_input(field_info: FieldInfo) -> QtWidgets.QWidget:
Enum: EnumInputWidget,
}

for type, widget in class_widgets.items():
if issubclass(field_info.annotation, type):
for input_type, widget in class_widgets.items():
if issubclass(field_info.annotation, input_type):
return widget(field_info)

return BaseInputWidget(field_info)
Expand Down Expand Up @@ -183,14 +183,14 @@ def textFromValue(self, value):
"""
return f"{round(value, self.decimals()):.{self.decimals()}g}"

def validate(self, input, pos) -> tuple[QtGui.QValidator.State, str, int]:
def validate(self, input_text, pos) -> tuple[QtGui.QValidator.State, str, int]:
"""Validate a string written into the spinbox.
Override of QtWidgets.QDoubleSpinBox.validate.
Parameters
----------
input : str
input_text : str
The string written into the spinbox.
pos : int
The current cursor position.
Expand All @@ -201,13 +201,13 @@ def validate(self, input, pos) -> tuple[QtGui.QValidator.State, str, int]:
The validation state of the input, the input string, and position.
"""
if "e" in input:
if "e" in input_text:
try:
self.setDecimals(-int(input.split("e")[-1]))
return (QtGui.QValidator.State.Acceptable, input, pos)
self.setDecimals(-int(input_text.split("e")[-1]))
return (QtGui.QValidator.State.Acceptable, input_text, pos)
except ValueError:
return (QtGui.QValidator.State.Intermediate, input, pos)
if "." in input and len(input.split(".")[-1]) != self.decimals():
self.setDecimals(len(input.split(".")[-1]))
return (QtGui.QValidator.State.Acceptable, input, pos)
return super().validate(input, pos)
return (QtGui.QValidator.State.Intermediate, input_text, pos)
if "." in input_text and len(input_text.split(".")[-1]) != self.decimals():
self.setDecimals(len(input_text.split(".")[-1]))
return (QtGui.QValidator.State.Acceptable, input_text, pos)
return super().validate(input_text, pos)
2 changes: 1 addition & 1 deletion tests/dialogs/test_project_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def test_verify_folder(contents, has_project):
def test_load_invalid_json():
"""If project loading produces an error (which it does for invalid JSON), raise that error in the textbox."""

def error(dir):
def error(ignored_dir):
raise ValueError("Project load error!")

view.presenter.load_project = error
Expand Down

0 comments on commit f514262

Please sign in to comment.