Skip to content

Commit

Permalink
refactor: re-enable the too-many-positional-arguments pylint check
Browse files Browse the repository at this point in the history
  • Loading branch information
bradenmacdonald committed Feb 19, 2025
1 parent 735f4e4 commit d8f7cb6
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
4 changes: 2 additions & 2 deletions openedx_learning/apps/authoring/components/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ def create_next_component_version(
return component_version


def create_component_and_version(
def create_component_and_version( # pylint: disable=too-many-positional-arguments
learning_package_id: int,
/,
component_type: ComponentType,
Expand Down Expand Up @@ -326,7 +326,7 @@ def component_exists_by_key(
return False


def get_components(
def get_components( # pylint: disable=too-many-positional-arguments
learning_package_id: int,
/,
draft: bool | None = None,
Expand Down
23 changes: 13 additions & 10 deletions openedx_learning/apps/authoring/containers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def check_unpinned_versions_in_defined_list(

def check_new_changes_in_defined_list(
entity_list: EntityList, # pylint: disable=unused-argument
publishable_entities_pk: list[int], # pylint: disable=unused-argument
publishable_entities_pks: list[int], # pylint: disable=unused-argument
) -> bool:
"""
[ 🛑 UNSTABLE ]
Expand All @@ -234,8 +234,9 @@ def check_new_changes_in_defined_list(
def create_container_version(
container_pk: int,
version_num: int,
*,
title: str,
publishable_entities_pk: list[int],
publishable_entities_pks: list[int],
entity_version_pks: list[int | None],
entity: PublishableEntity,
created: datetime,
Expand All @@ -249,7 +250,7 @@ def create_container_version(
container_pk: The ID of the container that the version belongs to.
version_num: The version number of the container.
title: The title of the container.
publishable_entities_pk: The IDs of the members of the container.
publishable_entities_pks: The IDs of the members of the container.
entity: The entity that the container belongs to.
created: The date and time the container version was created.
created_by: The ID of the user who created the container version.
Expand All @@ -266,7 +267,7 @@ def create_container_version(
created_by=created_by,
)
defined_list = create_defined_list_with_rows(
entity_pks=publishable_entities_pk,
entity_pks=publishable_entities_pks,
entity_version_pks=entity_version_pks,
)
container_version = ContainerEntityVersion.objects.create(
Expand All @@ -284,8 +285,9 @@ def create_container_version(

def create_next_container_version(
container_pk: int,
*,
title: str,
publishable_entities_pk: list[int],
publishable_entities_pks: list[int],
entity_version_pks: list[int | None],
entity: PublishableEntity,
created: datetime,
Expand All @@ -305,7 +307,7 @@ def create_next_container_version(
Args:
container_pk: The ID of the container to create the next version of.
title: The title of the container.
publishable_entities_pk: The IDs of the members current members of the container.
publishable_entities_pks: The IDs of the members current members of the container.
entity: The entity that the container belongs to.
created: The date and time the container version was created.
created_by: The ID of the user who created the container version.
Expand All @@ -332,7 +334,7 @@ def create_next_container_version(
# 6. Point frozen_list to None or defined_list
if check_new_changes_in_defined_list(
entity_list=last_version.defined_list,
publishable_entities_pk=publishable_entities_pk,
publishable_entities_pks=publishable_entities_pks,
):
# Only change if there are unpin versions in defined list, meaning last frozen list is None
# When does this has to happen? Before?
Expand All @@ -344,7 +346,7 @@ def create_next_container_version(
next_defined_list = create_next_defined_list(
previous_entity_list=last_version.defined_list,
new_entity_list=create_entity_list(),
entity_pks=publishable_entities_pk,
entity_pks=publishable_entities_pks,
entity_version_pks=entity_version_pks,
)
next_initial_list = get_entity_list_with_pinned_versions(
Expand Down Expand Up @@ -376,10 +378,11 @@ def create_next_container_version(
def create_container_and_version(
learning_package_id: int,
key: str,
*,
created: datetime,
created_by: int | None,
title: str,
publishable_entities_pk: list[int],
publishable_entities_pks: list[int],
entity_version_pks: list[int | None],
) -> ContainerEntityVersion:
"""
Expand All @@ -404,7 +407,7 @@ def create_container_and_version(
container_pk=container.publishable_entity.pk,
version_num=1,
title=title,
publishable_entities_pk=publishable_entities_pk,
publishable_entities_pks=publishable_entities_pks,
entity_version_pks=entity_version_pks,
entity=container.publishable_entity,
created=created,
Expand Down
27 changes: 14 additions & 13 deletions openedx_learning/apps/authoring/units/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def create_unit(
def create_unit_version(
unit: Unit,
version_num: int,
*,
title: str,
publishable_entities_pks: list[int],
entity_version_pks: list[int | None],
Expand All @@ -78,12 +79,12 @@ def create_unit_version(
container_entity_version = container_api.create_container_version(
unit.container_entity.pk,
version_num,
title,
publishable_entities_pks,
entity_version_pks,
unit.container_entity.publishable_entity,
created,
created_by,
title=title,
publishable_entities_pks=publishable_entities_pks,
entity_version_pks=entity_version_pks,
entity=unit.container_entity.publishable_entity,
created=created,
created_by=created_by,
)
unit_version = UnitVersion.objects.create(
unit=unit,
Expand Down Expand Up @@ -127,12 +128,12 @@ def create_next_unit_version(
# This currently allows for any publishable entity to be added to a unit.
container_entity_version = container_api.create_next_container_version(
unit.container_entity.pk,
title,
publishable_entities_pks,
entity_version_pks,
unit.container_entity.publishable_entity,
created,
created_by,
title=title,
publishable_entities_pks=publishable_entities_pks,
entity_version_pks=entity_version_pks,
entity=unit.container_entity.publishable_entity,
created=created,
created_by=created_by,
)
unit_version = UnitVersion.objects.create(
unit=unit,
Expand Down Expand Up @@ -163,7 +164,7 @@ def create_unit_and_version(
unit_version = create_unit_version(
unit,
1,
title,
title=title,
publishable_entities_pks=[],
entity_version_pks=[],
created=created,
Expand Down
1 change: 0 additions & 1 deletion pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ disable =
invalid-name,
django-not-configured,
consider-using-with,
too-many-positional-arguments,

[REPORTS]
output-format = text
Expand Down
1 change: 0 additions & 1 deletion pylintrc_tweaks
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ disable+=
invalid-name,
django-not-configured,
consider-using-with,
too-many-positional-arguments,
17 changes: 9 additions & 8 deletions tests/openedx_tagging/core/tagging/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@

def check_taxonomy(
data,
taxonomy_id,
name,
*,
taxonomy_id: int,
name: str,
description="",
enabled=True,
allow_multiple=True,
Expand Down Expand Up @@ -385,11 +386,11 @@ def test_create_taxonomy(self, user_attr: str | None, expected_status: int):
create_data["can_change_taxonomy"] = True
create_data["can_delete_taxonomy"] = True
create_data["can_tag_object"] = False
check_taxonomy(response.data, response.data["id"], **create_data)
check_taxonomy(response.data, taxonomy_id=response.data["id"], **create_data)
url = TAXONOMY_DETAIL_URL.format(pk=response.data["id"])

response = self.client.get(url)
check_taxonomy(response.data, response.data["id"], **create_data)
check_taxonomy(response.data, taxonomy_id=response.data["id"], **create_data)

def test_create_without_export_id(self):
url = TAXONOMY_LIST_URL
Expand All @@ -409,7 +410,7 @@ def test_create_without_export_id(self):
create_data["can_tag_object"] = False
check_taxonomy(
response.data,
response.data["id"],
taxonomy_id=response.data["id"],
export_id="2-taxonomy-data-3",
**create_data,
)
Expand Down Expand Up @@ -465,7 +466,7 @@ def test_update_taxonomy(self, user_attr, expected_status):
response = self.client.get(url)
check_taxonomy(
response.data,
response.data["id"],
taxonomy_id=response.data["id"],
**{
"name": "new name",
"description": "taxonomy description",
Expand Down Expand Up @@ -526,7 +527,7 @@ def test_patch_taxonomy(self, user_attr, expected_status):
response = self.client.get(url)
check_taxonomy(
response.data,
response.data["id"],
taxonomy_id=response.data["id"],
**{
"name": "new name",
"enabled": True,
Expand Down Expand Up @@ -1041,7 +1042,7 @@ def test_object_tags_remaining_http_methods(
("staff", "taxonomy", {}, ["Invalid"], status.HTTP_400_BAD_REQUEST, "abc.xyz"),
)
@ddt.unpack
def test_tag_object(self, user_attr, taxonomy_attr, taxonomy_flags, tag_values, expected_status, object_id):
def test_tag_object(self, user_attr, taxonomy_attr, taxonomy_flags, tag_values, expected_status, object_id): # pylint: disable=too-many-positional-arguments
if user_attr:
user = getattr(self, user_attr)
self.client.force_authenticate(user=user)
Expand Down

0 comments on commit d8f7cb6

Please sign in to comment.