Skip to content

super(..) -> super() #1385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KommuSoft
Copy link

@KommuSoft KommuSoft commented Mar 29, 2025

Probably less error prone, since all are how the PEP-3135 specifies it.

Summary by CodeRabbit

  • Refactor

    • Streamlined internal code by adopting modern syntax for class initializations and method calls, improving readability and long-term maintainability without changing functionality.
  • Tests

    • Updated test setups and configurations to reflect these improvements, ensuring consistent behavior and enhanced code clarity across the test suite.

Copy link

coderabbitai bot commented Mar 29, 2025

Walkthrough

This pull request refactors a large number of files across the codebase by replacing explicit superclass calls (e.g. super(ClassName, self)) with the simplified no-argument form (super()). The changes span modules for forms, fields, views, widgets, and various tests. The functionality, logic, and control flow remain entirely unchanged, with the modifications solely aimed at modernizing the code style and improving readability.

Changes

File(s) Change Summary
src/dal/forms.py, src/dal/forward.py, src/dal/views.py, src/dal/widgets.py, src/dal/test/case.py, src/dal/test/stories.py Updated explicit super(Class, self) calls to the simplified super() syntax in form initialization, post-clean methods, to_dict methods, view dispatch, and widget methods.
src/dal_contenttypes/fields.py, src/dal_queryset_sequence/fields.py, src/dal_queryset_sequence/tests/test_views.py, src/dal_queryset_sequence/views.py Simplified super() calls in field preparation, constructors, test setup, and queryset-related methods.
src/dal_select2/fields.py, src/dal_select2/widgets.py, src/dal_select2_queryset_sequence/fields.py, src/dal_select2_taggit/widgets.py Replaced explicit superclass references in field constructors, widget methods, and validators with the modern super() syntax.
test_project/custom_select2/test_functional.py, test_project/custom_select2/widgets.py, test_project/linked_data/test_forms.py, test_project/linked_data/test_functional.py, test_project/linked_data/urls.py, test_project/rename_forward/urls.py, test_project/secure_data/admin.py, test_project/secure_data/test_functional.py, test_project/select2_foreign_key/test_functional.py, test_project/select2_generic_foreign_key/test_functional.py, test_project/select2_generic_m2m/test_functional.py, test_project/select2_list/test_functional.py, test_project/select2_many_to_many/test_functional.py, test_project/select2_nestedadmin/test_functional.py, test_project/select2_nestedadmin/urls.py, test_project/select2_one_to_one/test_functional.py, test_project/select2_tagging/test_functional.py, test_project/select2_taggit/test_functional.py Modernized test setups, media property accesses, and view query method calls by switching from explicit to implicit super() calls, thus streamlining the syntax without changing any functionality.

Sequence Diagram(s)

(No sequence diagrams for this refactoring change.)

Poem

Hopping through lines of code so sleek,
I found a way to make it chic.
super() now leads the dance,
Simplifying every class’s stance,
With carrots and bytes, my joy peaks!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d829891 and 9824216.

📒 Files selected for processing (32)
  • src/dal/forms.py (2 hunks)
  • src/dal/forward.py (4 hunks)
  • src/dal/test/case.py (1 hunks)
  • src/dal/test/stories.py (2 hunks)
  • src/dal/views.py (2 hunks)
  • src/dal/widgets.py (3 hunks)
  • src/dal_contenttypes/fields.py (1 hunks)
  • src/dal_queryset_sequence/fields.py (1 hunks)
  • src/dal_queryset_sequence/tests/test_views.py (1 hunks)
  • src/dal_queryset_sequence/views.py (2 hunks)
  • src/dal_select2/fields.py (2 hunks)
  • src/dal_select2/widgets.py (3 hunks)
  • src/dal_select2_queryset_sequence/fields.py (1 hunks)
  • src/dal_select2_taggit/widgets.py (2 hunks)
  • test_project/custom_select2/test_functional.py (1 hunks)
  • test_project/custom_select2/widgets.py (1 hunks)
  • test_project/linked_data/test_forms.py (1 hunks)
  • test_project/linked_data/test_functional.py (1 hunks)
  • test_project/linked_data/urls.py (1 hunks)
  • test_project/rename_forward/urls.py (1 hunks)
  • test_project/secure_data/admin.py (1 hunks)
  • test_project/secure_data/test_functional.py (1 hunks)
  • test_project/select2_foreign_key/test_functional.py (1 hunks)
  • test_project/select2_generic_foreign_key/test_functional.py (1 hunks)
  • test_project/select2_generic_m2m/test_functional.py (1 hunks)
  • test_project/select2_list/test_functional.py (1 hunks)
  • test_project/select2_many_to_many/test_functional.py (1 hunks)
  • test_project/select2_nestedadmin/test_functional.py (1 hunks)
  • test_project/select2_nestedadmin/urls.py (1 hunks)
  • test_project/select2_one_to_one/test_functional.py (1 hunks)
  • test_project/select2_tagging/test_functional.py (1 hunks)
  • test_project/select2_taggit/test_functional.py (1 hunks)
🧰 Additional context used
🧬 Code Definitions (16)
test_project/custom_select2/test_functional.py (12)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/rename_forward/urls.py (5)
test_project/linked_data/urls.py (1)
  • get_queryset (9-16)
test_project/select2_nestedadmin/urls.py (1)
  • get_queryset (13-23)
test_project/secure_data/urls.py (1)
  • get_queryset (9-10)
src/dal/views.py (1)
  • get_queryset (106-112)
src/dal_queryset_sequence/views.py (1)
  • get_queryset (45-52)
test_project/linked_data/test_forms.py (12)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/select2_tagging/test_functional.py (12)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/select2_nestedadmin/urls.py (5)
test_project/linked_data/urls.py (1)
  • get_queryset (9-16)
test_project/rename_forward/urls.py (1)
  • get_queryset (9-21)
test_project/secure_data/urls.py (1)
  • get_queryset (9-10)
src/dal/views.py (1)
  • get_queryset (106-112)
src/dal_queryset_sequence/views.py (1)
  • get_queryset (45-52)
test_project/select2_many_to_many/test_functional.py (12)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/select2_foreign_key/test_functional.py (12)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/custom_select2/widgets.py (1)
src/dal_select2/widgets.py (1)
  • media (90-111)
test_project/select2_nestedadmin/test_functional.py (12)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/select2_generic_m2m/test_functional.py (12)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
test_project/select2_one_to_one/test_functional.py (12)
test_project/linked_data/test_forms.py (1)
  • setUp (12-20)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
src/dal_select2/fields.py (1)
src/dal/views.py (1)
  • validate (214-222)
test_project/select2_taggit/test_functional.py (9)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_list/test_functional.py (1)
  • setUp (28-31)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
src/dal_select2_taggit/widgets.py (2)
src/dal_select2/widgets.py (3)
  • build_attrs (72-78)
  • build_attrs (145-149)
  • value_from_datadict (151-158)
src/dal/widgets.py (1)
  • build_attrs (54-65)
test_project/select2_list/test_functional.py (14)
src/dal/test/case.py (2)
  • create_option (84-94)
  • create_option (100-104)
src/dal/test/stories.py (1)
  • create_option (308-321)
src/dal/forms.py (1)
  • save (143-160)
test_project/linked_data/test_functional.py (1)
  • setUp (17-25)
test_project/secure_data/test_functional.py (1)
  • setUp (15-22)
test_project/select2_generic_foreign_key/test_functional.py (1)
  • setUp (16-18)
test_project/select2_generic_m2m/test_functional.py (1)
  • setUp (12-15)
test_project/select2_many_to_many/test_functional.py (1)
  • setUp (17-19)
test_project/select2_tagging/test_functional.py (1)
  • setUp (11-14)
test_project/select2_one_to_one/test_functional.py (1)
  • setUp (17-19)
test_project/select2_taggit/test_functional.py (1)
  • setUp (11-17)
test_project/select2_foreign_key/test_functional.py (1)
  • setUp (15-18)
test_project/custom_select2/test_functional.py (1)
  • setUp (15-18)
test_project/select2_nestedadmin/test_functional.py (1)
  • setUp (17-20)
src/dal/views.py (5)
src/dal_queryset_sequence/views.py (1)
  • get_queryset (45-52)
src/dal_select2_queryset_sequence/views.py (1)
  • get_queryset (71-106)
test_project/linked_data/urls.py (1)
  • get_queryset (9-16)
test_project/rename_forward/urls.py (1)
  • get_queryset (9-21)
test_project/select2_nestedadmin/urls.py (1)
  • get_queryset (13-23)
🔇 Additional comments (47)
test_project/custom_select2/test_functional.py (1)

16-16: Modernized super() call syntax

The change from super(AdminForeignKeyTestCase, self).setUp() to super().setUp() follows PEP-3135 best practices, making the code more readable and less error-prone.

test_project/linked_data/urls.py (1)

10-10: Improved super() method call

Good update to use the modern no-argument super() syntax instead of the more verbose super(LinkedDataView, self).get_queryset(). This is consistent with PEP-3135 recommendations and simplifies maintenance.

test_project/secure_data/admin.py (1)

9-9: Modernized super() call syntax

The simplified super() call improves code readability and maintainability. This change aligns with PEP-3135 recommendations and makes the code less prone to errors during future refactoring.

src/dal_contenttypes/fields.py (1)

42-42: Updated to modern super() syntax

Good change from super(ContentTypeModelMultipleFieldMixin, self).prepare_value(v) to super().prepare_value(v). This simplified syntax is more maintainable, particularly if the class were to be renamed in the future.

test_project/select2_taggit/test_functional.py (1)

12-12: Modernized super() Call in setUp Method
The updated super().setUp() call at line 12 correctly implements the no-argument form as suggested by PEP-3135. This change improves readability without affecting the existing functionality.

test_project/rename_forward/urls.py (1)

10-10: Simplified super() Syntax in get_queryset
The replacement of the explicit call with super().get_queryset() (line 10) aligns with modern Python best practices. This refactor does not change the business logic but does improve clarity and reduces maintenance overhead.

test_project/custom_select2/widgets.py (1)

11-11: Updated Superclass Access for the media Property
Using super().media at line 11 streamlines the property accessor and removes the unnecessary explicit class name. This approach increases readability while functioning identically to the old code.

src/dal_queryset_sequence/tests/test_views.py (1)

24-24: Refactored setUpClass Super Call
The change to super().setUpClass() at line 24 modernizes the test setup by employing the no-argument form. This succinct syntax improves maintainability and adheres to PEP-3135 guidelines without affecting test functionality.

test_project/select2_generic_foreign_key/test_functional.py (1)

17-17: Streamlined super() in the setUp Method
The adjustment from an explicit class-based call to super().setUp() at line 17 is correct and aligns the code with modern Python practices. This refactoring enhances clarity and consistency across the test cases.

test_project/select2_many_to_many/test_functional.py (1)

18-18: Great use of simplified super() syntax!

Replacing super(AdminManyToManyTestCase, self).setUp() with super().setUp() follows PEP-3135 guidelines and makes the code more maintainable. This modern syntax eliminates the risk of errors during class renaming and improves readability.

test_project/select2_one_to_one/test_functional.py (1)

18-18: Good modernization of super() call!

Changing to the no-argument form super().setUp() follows PEP-3135 best practices. This is consistent with the changes in other test files and improves code maintainability.

src/dal_select2_taggit/widgets.py (2)

13-13: Good use of simplified super() syntax!

The modern no-argument form super().build_attrs() follows PEP-3135 recommendations, making the code more maintainable and less prone to errors during refactoring.


23-24: Improved readability with no-argument super() form!

Replacing the verbose super(TaggitSelect2, self).value_from_datadict() with the concise super().value_from_datadict() follows Python 3 best practices while preserving functionality.

test_project/linked_data/test_functional.py (1)

18-18: Clean use of modern super() syntax!

Using super().setUp() instead of the class-explicit form follows PEP-3135 recommendations and maintains consistency with the changes across other test files in this PR.

test_project/linked_data/test_forms.py (1)

12-13: Simplified Super() Call in setUp()

The update from an explicit call (super(LinkedDataFormTest, self).setUp()) to the simpler super().setUp() improves readability and adheres to modern Python practices outlined in PEP-3135 without affecting functionality.

test_project/secure_data/test_functional.py (1)

12-13: Modernized Super() Call

Replacing the explicit superclass call with super().setUp() modernizes the test setup method and enhances code clarity while retaining the same behavior.

test_project/select2_nestedadmin/urls.py (1)

23-23: Refined Super() Usage in get_queryset()

The revision to use super().get_queryset() in the get_queryset method cleanly modernizes the code by removing the outdated explicit class reference. This change is fully consistent with PEP-3135 guidelines.

src/dal/forms.py (2)

78-81: Modernized Constructor with Super()

The change in the constructor from super(FutureModelForm, self).__init__(*args, **kwargs) to super().__init__(*args, **kwargs) streamlines the code and removes unnecessary verbosity while maintaining the original behavior.


88-91: Simplified Super() Call in _post_clean()

Updating the call to super()._post_clean() in the _post_clean method both simplifies the syntax and follows the modern convention, ensuring consistency with the rest of the codebase.

test_project/select2_nestedadmin/test_functional.py (1)

16-17: Concise Super() Call in setUp()

The refactor to replace the explicit superclass call with super().setUp() in the setUp method cleans up the code and aligns with current Python style recommendations, without impacting functionality.

test_project/select2_generic_m2m/test_functional.py (1)

12-15: Modernized super() call in setUp method is correctly applied.
Changing from an explicit call to super(AdminGenericM2MBase, self).setUp() to the simplified super().setUp() improves readability and is in full compliance with PEP‑3135. Just verify that the multiple‐inheritance chain resolves as expected.

src/dal/widgets.py (5)

51-52: Simplified super() in init is effective.
Using super().__init__(*args, **kwargs) in place of the explicit superclass call produces cleaner initialization code and adheres to modern Python practices.


54-57: Modernized super() usage in build_attrs is correctly implemented.
Switching to super().build_attrs(*args, **kwargs) removes redundancy and improves clarity in attribute construction.


121-124: Updated super() invocation in render_options streamlines the method.
The change to super().render_options(*args) is concise while preserving the original rendering logic.


141-144: Consistent use of super() in optgroups enhances code readability.
Updating to super().optgroups(name, value, attrs) aligns with modern Python style and reduces potential misconfigurations in multiple inheritance scenarios.


147-150: Cleaner super() call in render method improves maintainability.
The transition to super().render(name, value, attrs, **kwargs) avoids hardcoding the class name and reduces boilerplate.

src/dal_select2_queryset_sequence/fields.py (1)

41-45: Modernized super() call in init is properly applied.
Replacing the explicit call with super().__init__(*args, **kwargs) streamlines the code in Select2GenericForeignKeyModelField and keeps it consistent with similar changes elsewhere in the codebase.

test_project/select2_tagging/test_functional.py (1)

6-9: Updated super() call in setUp method enhances consistency.
Switching to super().setUp() in the TagSelect2AdminTestMixin now follows Python 3 best practices, making the call less error prone and easier to maintain.

test_project/select2_list/test_functional.py (2)

11-14: Modernized super() call in create_option is applied correctly.
The updated line option = super().create_option() simplifies the call while retaining the expected behavior.


18-21: Consistent update of super() in setUp method is commendable.
Changing to super().setUp() within the setUp method is a simple yet effective improvement for clarity and consistency across the test cases.

src/dal_queryset_sequence/fields.py (1)

163-163: Modernized super() Call in Constructor.
The change from an explicit superclass reference to using super().__init__(*args, **kwargs) adheres to PEP-3135 and improves readability without altering functionality.

src/dal/test/case.py (1)

100-104: Simplified super() in create_option Method.
Replacing the verbose super(ContentTypeOptionMixin, self).create_option() with super().create_option() modernizes the code and aligns with Python 3 best practices while keeping the behavior intact.

test_project/select2_foreign_key/test_functional.py (1)

15-19: Updated super() Call in setUp Method.
Switching to super().setUp() improves the readability of the test setup by using the concise, modern Python syntax. This change is consistent with similar updates in other test modules.

src/dal_queryset_sequence/views.py (2)

34-34: Simplified super() in has_more Method.
Updating the call from super(BaseQuerySetSequenceView, self).has_more(context) to super().has_more(context) streamlines the code without changing its behavior.


47-47: Simplified super() in get_queryset Method.
Using super().get_queryset() is consistent with modern Python usage and enhances code readability while preserving the original logic.

src/dal_select2/fields.py (2)

41-45: Streamlined super() Call in init of Select2ListChoiceField.
Replacing the explicit call super(Select2ListChoiceField, self).__init__(...) with super().__init__(...) adheres to Python 3 conventions, making the code cleaner and easier to read.

🧰 Tools
🪛 Ruff (0.8.2)

43-43: Star-arg unpacking after a keyword argument is strongly discouraged

(B026)


50-53: Modernized super() Call in validate Method of Select2ListCreateChoiceField.
The update to super().validate(value) simplifies the method call while preserving the original validation logic, aligning the code with modern Python practices.

src/dal/test/stories.py (1)

237-237: Simplified super() Call in InlineSelectOption Initialization.

The update to call super().__init__(case, **kwargs) (line 237) correctly adopts the Python 3 concise syntax. This change enhances readability while preserving the original functionality.

src/dal/views.py (2)

57-59: Modernized super() in dispatch Method.

The change at line 58, replacing an explicit superclass call with super().dispatch(request, *args, **kwargs), adheres to PEP-3135 and improves clarity without impacting functionality.


108-108: Updated super() Call in get_queryset Method.

The revised call (qs = super().get_queryset()) at line 108 correctly follows modern Python practices while maintaining the intended behavior.

src/dal/forward.py (4)

59-67: Refactored super() Usage in Field.to_dict.

The update to use d = super().to_dict() in the Field.to_dict method simplifies the code and maintains the intended merging of dictionary values.


89-97: Simplified super() in Const.to_dict.

Changing to d = super().to_dict() in the Const.to_dict method is correctly implemented and aligns with the modern, concise syntax without affecting functionality.


133-141: Modernized super() in JavaScript.to_dict.

The modification to use d = super().to_dict() in the JavaScript.to_dict method enhances readability and follows Python 3 best practices while preserving behavior.


162-170: Consistent Use of super() in Self.to_dict.

Updating to d = super().to_dict() in the Self.to_dict method ensures consistency across the forward declaration classes and reinforces modern coding standards.

src/dal_select2/widgets.py (3)

72-75: Updated super() Call in Select2WidgetMixin.build_attrs.

The refactor at line 74, replacing the explicit call with attrs = super().build_attrs(*args, **kwargs), correctly modernizes the method while preserving its functionality.


145-149: Simplified super() in TagSelect2.build_attrs.

Switching to attrs = super().build_attrs(*args, **kwargs) within TagSelect2.build_attrs is a proper update that streamlines the code and maintains the expected attribute configuration.


157-159: Refined super() Call in TagSelect2.value_from_datadict.

The change to values = super().value_from_datadict(data, files, name) effectively simplifies the call, ensuring that data retrieval remains robust before joining the results.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant