Sourcery refactored 13.0 branch#1
Conversation
| # Mix. image colors using addition method | ||
| RGBA_WHITE = (255, 255, 255, 255) | ||
| for i in range(0, height * width): | ||
| for i in range(height * width): |
There was a problem hiding this comment.
Function image_to_rgb refactored with the following changes:
- Replace range(0, x) with range(x) (
remove-zero-from-range)
|
|
||
| URL_BASE = "/web_company_color/static/src/scss/" | ||
| URL_SCSS_GEN_TEMPLATE = URL_BASE + "custom_colors.%d.gen.scss" | ||
| URL_SCSS_GEN_TEMPLATE = f"{URL_BASE}custom_colors.%d.gen.scss" |
There was a problem hiding this comment.
Lines 11-11 refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
| result = super().write(values) | ||
|
|
||
| if any([field in values for field in fields_to_check]): | ||
| if any(field in values for field in fields_to_check): |
There was a problem hiding this comment.
Function ResCompany.write refactored with the following changes:
- Replace unneeded comprehension with generator (
comprehension-to-generator)
| values.update( | ||
| { | ||
| "color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"), | ||
| "color_navbar_bg_hover": ( | ||
| values.get("color_navbar_bg_hover") | ||
| or "$o-navbar-inverse-link-hover-bg" | ||
| ), | ||
| "color_navbar_text": (values.get("color_navbar_text") or "#FFF"), | ||
| } | ||
| ) | ||
| values |= { | ||
| "color_navbar_bg": (values.get("color_navbar_bg") or "$o-brand-odoo"), | ||
| "color_navbar_bg_hover": ( | ||
| values.get("color_navbar_bg_hover") | ||
| or "$o-navbar-inverse-link-hover-bg" | ||
| ), | ||
| "color_navbar_text": (values.get("color_navbar_text") or "#FFF"), | ||
| } |
There was a problem hiding this comment.
Function ResCompany._scss_get_sanitized_values refactored with the following changes:
- Merge dictionary updates via the union operator (
dict-assign-update-to-union)
| if not self.company_colors: | ||
| return "// No Web Company Color SCSS Content\n" | ||
| return self.SCSS_TEMPLATE % self._scss_get_sanitized_values() | ||
| return ( | ||
| self.SCSS_TEMPLATE % self._scss_get_sanitized_values() | ||
| if self.company_colors | ||
| else "// No Web Company Color SCSS Content\n" | ||
| ) |
There was a problem hiding this comment.
Function ResCompany._scss_generate_content refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else) - Replace if statement with if expression (
assign-if-exp) - Swap if/else branches of if expression to remove negation (
swap-if-expression)
| news = bus_bus.search(domain) - existing | ||
| self.assertEqual(1, len(news)) | ||
| test_msg.update({"type": DEFAULT}) | ||
| test_msg["type"] = DEFAULT |
There was a problem hiding this comment.
Function TestResUsers.test_notify_default refactored with the following changes:
- Add single value to dictionary directly rather than using update() (
simplify-dictionary-update)
| version_list = [] | ||
| for url in urls: | ||
| version_list.append(url.split("/")[3]) | ||
| version_list = [url.split("/")[3] for url in urls] |
There was a problem hiding this comment.
Function PWA.service_worker refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| for value in range(min_value, max_value + 1): | ||
| options.append((value, str(value))) | ||
| return options | ||
| return [(value, str(value)) for value in range(min_value, max_value + 1)] |
There was a problem hiding this comment.
Function WebWidgetDropdownDynamicExample.values_int_field refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| view_id = self.env.ref( | ||
| "web_widget_x2many_2d_matrix_example.%s" % view_xmlid, | ||
| ).id | ||
| view_id = self.env.ref(f"web_widget_x2many_2d_matrix_example.{view_xmlid}").id |
There was a problem hiding this comment.
Function X2MDemo._open_x2m_matrix refactored with the following changes:
- Replace interpolated string formatting with f-string (
replace-interpolation-with-fstring)
| ( | ||
| (4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id) | ||
| if rec.line_ids.filtered(lambda x: x.user_id == usr) | ||
| else ( | ||
| 0, | ||
| 0, | ||
| { | ||
| "name": "{}'s task on {}".format(usr.name, rec.name), | ||
| "name": f"{usr.name}'s task on {rec.name}", | ||
| "demo_id": rec.id, | ||
| "user_id": usr.id, | ||
| }, | ||
| ) | ||
| # if there isn't a demo line record for the user, create a new one | ||
| if not rec.line_ids.filtered(lambda x: x.user_id == usr) else | ||
| # otherwise, return the line | ||
| (4, rec.line_ids.filtered(lambda x: x.user_id == usr)[0].id) |
There was a problem hiding this comment.
Function X2mMatrixDemoWiz._default_line_ids refactored with the following changes:
- Swap if/else branches of if expression to remove negation (
swap-if-expression) - Replace call to format with f-string (
use-fstring-for-formatting)
This removes the following comments ( why? ):
# if there isn't a demo line record for the user, create a new one
# otherwise, return the line
Branch
13.0refactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
13.0branch, then run:Help us improve this pull request!