Skip to content

Commit

Permalink
Add ruff rules for naming, performance, simplification, and timezones
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss committed Nov 27, 2023
1 parent bd3d975 commit 55d7f5c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion formtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def form_hmac(form):
for bf in form:
# Get the value from the form data. If the form allows empty or hasn't
# changed then don't call clean() to avoid trigger validation errors.
if form.empty_permitted and not form.has_changed():
if form.empty_permitted and not form.has_changed(): # noqa: SIM108
value = bf.data or ''
else:
value = bf.field.clean(bf.data) or ''
Expand Down
5 changes: 1 addition & 4 deletions formtools/wizard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,7 @@ def get(self, *args, **kwargs):
if 'reset' in self.request.GET:
self.storage.reset()
self.storage.current_step = self.steps.first
if self.request.GET:
query_string = "?%s" % self.request.GET.urlencode()
else:
query_string = ""
query_string = '?%s' % self.request.GET.urlencode() if self.request.GET else ''
return redirect(self.get_step_url(self.steps.current) + query_string)

# is the current step the "done" name/view?
Expand Down
8 changes: 5 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ line_length = 79
multi_line_output = 5

[tool.ruff]
ignore = ["PLW2901"]
line-length = 119
select = ["ASYNC", "C4", "C90", "DJ", "E", "F", "PL", "UP", "W"]
select = ["ASYNC", "C4", "C90", "DJ", "DTZ", "E", "F", "N", "PERF", "PL", "SIM", "UP", "W"]

[tool.ruff.per-file-ignores]
"tests/wizard/test_forms.py" = ["DJ007", "DJ008"]
"formtools/wizard/storage/base.py" = ["PLW2901"]
"formtools/wizard/views.py" = ["N805", "PLW2901"]
"tests/wizard/storage.py" = ["DTZ005"]
"tests/wizard/test_forms.py" = ["DJ007", "DJ008", "N803"]
"tests/wizard/wizardtests/tests.py" = ["DJ007"]
2 changes: 1 addition & 1 deletion tests/wizard/namedwizardtests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def done(self, form_list, **kwargs):
'all_cleaned_data': self.get_all_cleaned_data()
})

for form in self.form_list.keys():
for form in self.form_list:
c[form] = self.get_cleaned_data_for_step(form)

c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail')
Expand Down
2 changes: 1 addition & 1 deletion tests/wizard/wizardtests/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def done(self, form_list, **kwargs):
'all_cleaned_data': self.get_all_cleaned_data(),
})

for form in self.form_list.keys():
for form in self.form_list:
c[form] = self.get_cleaned_data_for_step(form)

c['this_will_fail'] = self.get_cleaned_data_for_step('this_will_fail')
Expand Down

0 comments on commit 55d7f5c

Please sign in to comment.