Skip to content
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

Mjg/mypy #250

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisf

quality: ## check coding style with pycodestyle and pylint
pylint openedx_filters test_utils *.py
mypy
pycodestyle openedx_filters *.py
pydocstyle openedx_filters *.py
isort --check-only --diff --recursive test_utils openedx_filters *.py test_settings.py
Expand Down
9 changes: 9 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[mypy]
allow_untyped_globals = False
plugins =
mypy_django_plugin.main,
files =
openedx_filters

[mypy.plugins.django-stubs]
django_settings_module = "test_utils.test_settings"
17 changes: 14 additions & 3 deletions openedx_filters/course_authoring/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,26 @@

class LMSPageURLRequested(OpenEdxPublicFilter):
"""
Custom class used to get lms page url filters and its custom methods.
Filter used to modify the URL of the page requested by the user.

This filter is triggered when a user loads a page in Studio that references an LMS page, allowing the filter to
modify the URL of the page requested by the user.

Filter Type:
org.openedx.course_authoring.lms.page.url.requested.v1

Trigger:
- Repository: openedx/edx-platform
- Path: cms/djangoapps/contentstore/asset_storage_handler.py
- Function or Method: get_asset_json
"""

filter_type = "org.openedx.course_authoring.lms.page.url.requested.v1"

@classmethod
def run_filter(cls, url, org):
def run_filter(cls, url: str, org: str) -> tuple[str, str]:
"""
Execute a filter with the signature specified.
Process the inputs using the configured pipeline steps to modify the URL of the page requested by the user.

Arguments:
url (str): the URL of the page to be modified.
Expand Down
Loading
Loading