Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Add codespell pre-commit hook (#2855)
sarayourfriend5678bdcd6435
diff --git a/.codespell/README.md b/.codespell/README.mdnew file mode 100644index 000000000..f05a81e70--- /dev/null+++ b/.codespell/README.md@@ -0,0 +1,3 @@+# Codespell Configuration++These files are documented at <https://docs.openverse.org/meta/codespell.html>.diff --git a/.codespell/dictionary.txt b/.codespell/dictionary.txtnew file mode 100644index 000000000..e69de29bbdiff --git a/.codespell/ignore_lines.txt b/.codespell/ignore_lines.txtnew file mode 100644index 000000000..8b4b19ad2--- /dev/null+++ b/.codespell/ignore_lines.txt@@ -0,0 +1,18 @@+;; Please include filenames and explanations for each ignored line.+;; See https://docs.openverse.org/meta/codespell.html for docs.++;; .github/workflows/release-app.yml+;; The release-drafter/release-drafter configuration variable name cannot be changed+ commitish: main++;; frontend/src/locales/scripts/en.json5+;; Prettier insists we escape a single quote rather than the double quotes and codespell+;; does not understand the escaped `\'t` as "couldn't". It instead just sees "couldn".+ heading: 'We couldn\'t find anything for "{query}".',++;; catalog/tests/dags/providers/provider_api_scripts/test_wikimedia_commons.py+;; "Titel" matches "title", but the phrase is in Dutch, not English, so "titel"+;; is actually correct. Similarly, "als" incorrectly matches to "also" in the same+;; block of Dutch text.+ "Identificatie Titel(s): Allegorie op kunstenaar Francesco Mazzoli, "+ "bekend als Parmigianino"diff --git a/.codespell/ignore_words.txt b/.codespell/ignore_words.txtnew file mode 100644index 000000000..6d3364212--- /dev/null+++ b/.codespell/ignore_words.txt@@ -0,0 +1,8 @@+;; Please include explanations for each ignored word.+;; See https://docs.openverse.org/meta/codespell.html for docs.++;; Jest's `afterAll` hook incorrectly matched+afterall++;; `nd` references licence part+nddiff --git a/.github/dependabot.yml b/.github/dependabot.ymlindex 7bb842699..6cbf87b8e 100644--- a/.github/dependabot.yml+++ b/.github/dependabot.yml@@ -36,7 +36,7 @@ updates:- "🧱 stack: ingestion server"- dependencies- # Enable version updates for Python dev-libs in the calalog+ # Enable version updates for Python dev-libs in the catalog## `requirements-dev.txt` can be updated more frequently than# `requirements_prod.txt` since they are not pinned by the Airflow constraintsdiff --git a/.isort.cfg b/.isort.cfgdeleted file mode 100644index faae1fce7..000000000--- a/.isort.cfg+++ /dev/null@@ -1,8 +0,0 @@-[settings]-profile=black--sections=FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER-known_django=django,rest_framework-known_first_party=conf,api,ingestion_server,common,data_refresh,database,maintenance,oauth2,providers,retired--lines_after_imports=2diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex ad85790fa..3dfc4ae42 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -108,6 +108,40 @@ repos:hooks:- id: actionlint-docker+ - repo: https://github.com/codespell-project/codespell+ rev: v2.2.5+ hooks:+ - id: codespell+ args: [+ # Pass skip configuration as command line arguments rather than in the+ # config file because neither cfg nor TOML support splitting this argument+ # across multiple lines.+ # Globs must match the Python `glob` module's format:+ # https://docs.python.org/3/library/glob.html#module-glob+ "-S",+ "sample_data/**",+ "-S",+ "frontend/test/tapes/**",+ "-S",+ "frontend/test/playwright/e2e/resources/**",+ "-S",+ "frontend/test/unit/fixtures/**",+ "-S",+ "catalog/tests/dags/providers/provider_api_scripts/resources/**",+ "-S",+ "catalog/tests/dags/common/test_resources/**",+ # Test locales are non-English and therefore should not be checked by codespell+ "-S",+ "frontend/test/locales/*.json",+ "-S",+ "pnpm-lock.yaml",+ # Write changes in place+ "-w",+ ]+ additional_dependencies:+ # Support pyproject.toml configuration+ - tomli+- repo: local # More local hooks are defined at the top.hooks:- id: typesdiff --git a/.ruff.toml b/.ruff.tomldeleted file mode 100644index 8900448ea..000000000--- a/.ruff.toml+++ /dev/null@@ -1,5 +0,0 @@-[per-file-ignores]-"*test*" = ["E501"]-"*__init__*" = ["F401"]-"*wsgi.py" = ["E402"]-"*settings/__init__.py" = ["F403"]diff --git a/api/api/serializers/media_serializers.py b/api/api/serializers/media_serializers.pyindex a0a90c8e7..9da1b411b 100644--- a/api/api/serializers/media_serializers.py+++ b/api/api/serializers/media_serializers.py@@ -498,7 +498,7 @@ class MediaSerializer(BaseModelSerializer):# that providers have themselves marked as mature, unsafe, etc,# it isn't clear (aside from Flickr, where we use "safe search").# What is clear is that we do not need to handle provider reported- # sensitivity here because it simply does not occurr in our database.+ # sensitivity here because it simply does not occur in our database.# That is _very_ convenient because provider supplied maturity is# much more complex to derive. Its condition is that the result# has no report _and_ has `mature=true` on the document in ES.diff --git a/api/api/utils/oauth2_helper.py b/api/api/utils/oauth2_helper.pyindex c8bfebad3..c6df07202 100644--- a/api/api/utils/oauth2_helper.py+++ b/api/api/utils/oauth2_helper.py@@ -30,7 +30,7 @@ def get_token_info(token: str):application = models.ThrottledApplication.objects.get(accesstoken=token)except models.ThrottledApplication.DoesNotExist:# Critical because it indicates a data integrity problem.- # In practice should never occur so long as the preceeding+ # In practice should never occur so long as the preceding# operation to retrieve the access token was successful.logger.critical("Failed to find application associated with access token.")return _no_resultdiff --git a/api/api/utils/pagination.py b/api/api/utils/pagination.pyindex 02e91be3f..83a0008ea 100644--- a/api/api/utils/pagination.py+++ b/api/api/utils/pagination.py@@ -11,7 +11,7 @@ class StandardPagination(PageNumberPagination):super().__init__(*args, **kwargs)self.result_count = None # populated laterself.page_count = None # populated later- self.page = 1 # default, get's updated when necessary+ self.page = 1 # default, gets updated when necessarydef get_paginated_response(self, data):return Response(diff --git a/api/test/unit/controllers/test_search_controller.py b/api/test/unit/controllers/test_search_controller.pyindex 21feb62d1..3ed985456 100644--- a/api/test/unit/controllers/test_search_controller.py+++ b/api/test/unit/controllers/test_search_controller.py@@ -125,7 +125,7 @@ def test_paginate_with_dead_link_mask_new_search(If we do not have a query mask to represent this, but we request page 2 of size 2,where should we start the query? We would want to start at index 2 (skipping thefirst page of 2 results), but in actuality we need to start at index 6 because- the first page of 2 confirmed live results actually encompases the range from+ the first page of 2 confirmed live results actually encompasses the range from1 to 5, as that is the smallest window in which we can fulfill the requested_first_ page of results that we're skipping.@@ -629,7 +629,7 @@ def test_no_post_process_results_recursion(# - We clear the redis cache between each test, meaning there is no query-based# dead link mask. This forces `from` to 0 for each case.# - Recursion should only continue while results still exist that could fulfill- # the requested page size. Once the available hits are exhaused, the function+ # the requested page size. Once the available hits are exhausted, the function# should stop recursing. This is why exceeding or matching the available# hits is significant.(diff --git a/api/test/unit/utils/test_search_context.py b/api/test/unit/utils/test_search_context.pyindex a1c1489c3..b20817acf 100644--- a/api/test/unit/utils/test_search_context.py+++ b/api/test/unit/utils/test_search_context.py@@ -62,7 +62,7 @@ def test_sensitive_text()assert (mock.total_matches == 0- ), "There should be zero requests to ES if the settting is disabled"+ ), "There should be zero requests to ES if the setting is disabled"pook.off()else:search_context = SearchContext.build(results, media_type_config.origin_index)diff --git a/catalog/DAGs.md b/catalog/DAGs.mdindex ca9201e24..fae2dcb72 100644--- a/catalog/DAGs.md+++ b/catalog/DAGs.md@@ -328,7 +328,7 @@ which caused DAG failures during the `update_batches` step.Check for DAGs that have silenced Slack alerts or skipped errors which may needto be turned back on.-When a DAG has known failures, it can be ommitted from Slack error reporting by+When a DAG has known failures, it can be omitted from Slack error reporting byadding an entry to the `SILENCED_SLACK_NOTIFICATIONS` Airflow variable.Similarly, errors that occur during the `pull_data` step may be configured toskip and allow ingestion to continue, using the `SKIPPED_INGESTION_ERRORS`@@ -341,8 +341,8 @@ The `check_silenced_dags` DAG iterates over the entries in theverifies that the associated GitHub issues are still open. If an issue has beenclosed, it is assumed that the entry should be removed, and an alert is sent toprompt manual update of the configuration. This prevents developers from-forgetting to reenable Slack reporting or turnoff error skipping after the issue-has been resolved.+forgetting to re-enable Slack reporting or turnoff error skipping after the+issue has been resolved.The DAG runs weekly.diff --git a/catalog/dags/common/loader/reporting.py b/catalog/dags/common/loader/reporting.pyindex 08625054a..53484aba2 100644--- a/catalog/dags/common/loader/reporting.py+++ b/catalog/dags/common/loader/reporting.py@@ -141,7 +141,7 @@ def report_completion()if skip_report_completion(duration, record_counts_by_media_type):raise AirflowSkipException(- "An upstream failure occured and no rows were loaded"+ "An upstream failure occurred and no rows were loaded")# List record count per media typediff --git a/catalog/dags/common/loader/sql.py b/catalog/dags/common/loader/sql.pyindex ca9401820..1e6089fbd 100644--- a/catalog/dags/common/loader/sql.py+++ b/catalog/dags/common/loader/sql.py@@ -245,7 +245,7 @@ def _is_tsv_column_from_different_version(column: Column, media_type: str, tsv_version: str) -> bool:"""- Check that a column appears in the available columns for a TSV verison.+ Check that a column appears in the available columns for a TSV version.Check that column is a column that exists in TSV files (unlike the db-onlycolumns like IDENTIFIER or CREATED_ON, or calculated values likediff --git a/catalog/dags/data_refresh/data_refresh_task_factory.py b/catalog/dags/data_refresh/data_refresh_task_factory.pyindex 6f6d78d14..d735e5753 100644--- a/catalog/dags/data_refresh/data_refresh_task_factory.py+++ b/catalog/dags/data_refresh/data_refresh_task_factory.py@@ -118,7 +118,7 @@ def create_data_refresh_task_group(# filtered index creation process, even if it was triggered immediately after# filtered index creation. However, it is safer to avoid the possibility# of the race condition altogether.- # ``execution_date_fn`` is used to find the most recent run becuase+ # ``execution_date_fn`` is used to find the most recent run because# the filtered index createion DAGs are unscheduled so we can't derive# anything from the execution date of the current data refresh DAG.create_filtered_index_dag_id = (diff --git a/catalog/dags/maintenance/check_silenced_dags.py b/catalog/dags/maintenance/check_silenced_dags.pyindex 3192972b7..dcb4b9f46 100644--- a/catalog/dags/maintenance/check_silenced_dags.py+++ b/catalog/dags/maintenance/check_silenced_dags.py@@ -4,7 +4,7 @@Check for DAGs that have silenced Slack alerts or skipped errors which may need to beturned back on.-When a DAG has known failures, it can be ommitted from Slack error reporting by adding+When a DAG has known failures, it can be omitted from Slack error reporting by addingan entry to the `SILENCED_SLACK_NOTIFICATIONS` Airflow variable. Similarly, errors thatoccur during the `pull_data` step may be configured to skip and allow ingestion tocontinue, using the `SKIPPED_INGESTION_ERRORS` Airflow variable. These variables are@@ -16,7 +16,7 @@ The `check_silenced_dags` DAG iterates over the entries in the`SILENCED_SLACK_NOTIFICATIONS` and `SKIPPED_INGESTION_ERRORS` configurations andverifies that the associated GitHub issues are still open. If an issue has been closed,it is assumed that the entry should be removed, and an alert is sent to prompt manual-update of the configuration. This prevents developers from forgetting to reenable Slack+update of the configuration. This prevents developers from forgetting to re-enable Slackreporting or turnoff error skipping after the issue has been resolved.The DAG runs weekly.@@ -66,7 +66,7 @@ def get_dags_with_closed_issues(if github_issue.get("state") == "closed":# If the associated issue has been closed, this DAG can have- # alerting reenabled for this predicate.+ # alerting re-enabled for this predicate.dags_to_reenable.append((dag_id,diff --git a/catalog/dags/providers/provider_api_scripts/metropolitan_museum.py b/catalog/dags/providers/provider_api_scripts/metropolitan_museum.pyindex fd62406b5..1d6b5152b 100644--- a/catalog/dags/providers/provider_api_scripts/metropolitan_museum.py+++ b/catalog/dags/providers/provider_api_scripts/metropolitan_museum.py@@ -68,7 +68,7 @@ class MetMuseumDataIngester(ProviderDataIngester):def get_batch_data(self, response_json):if response_json:self.object_ids_retrieved = response_json["total"]- # A single objet d'art may have more than one image (and therefore more+ # A single work may have more than one image (and therefore more# than one record) associated with it, but there are generally on the order# of 10 or fewer records per object.logger.info(f"Total objects found {self.object_ids_retrieved}")diff --git a/catalog/docs/provider_data_ingester_faq.md b/catalog/docs/provider_data_ingester_faq.mdindex 9adb39798..b6848faab 100644--- a/catalog/docs/provider_data_ingester_faq.md+++ b/catalog/docs/provider_data_ingester_faq.md@@ -154,7 +154,7 @@ provider. Instead, several requests need to be made in sequence until acomplex behavior.```python-# Psuedo code serves as an example+# Pseudo code serves as an exampledef get_response_json(self, query_params: dict, endpoint: str | None = None, **kwargs):diff --git a/catalog/tests/dags/maintenance/test_check_silenced_dags.py b/catalog/tests/dags/maintenance/test_check_silenced_dags.pyindex 800a99f0b..734fcbbd6 100644--- a/catalog/tests/dags/maintenance/test_check_silenced_dags.py+++ b/catalog/tests/dags/maintenance/test_check_silenced_dags.py@@ -17,7 +17,7 @@ p = pytest.param@pytest.mark.parametrize("silenced_dags, dags_to_reenable, should_send_alert",(- # No Dags to reenable, task should skip+ # No Dags to re-enable, task should skipp({},[],@@ -25,7 +25,7 @@ p = pytest.parammarks=pytest.mark.raises(exception=AirflowSkipException),id="none to re-enable",),- # One DAG to reenable+ # One DAG to re-enablep({"dag_a_id": [@@ -45,7 +45,7 @@ p = pytest.paramTrue,id="one to re-enable",),- # One DAG, multiple notifications to reenable+ # One DAG, multiple notifications to re-enablep({"dag_a_id": [@@ -74,7 +74,7 @@ p = pytest.paramTrue,id="one to re-enable, multiple notifications",),- # Multiple DAGs to reenable+ # Multiple DAGs to re-enablep({"dag_a_id": [diff --git a/catalog/tests/templates/test_create_provider_ingester.py b/catalog/tests/templates/test_create_provider_ingester.pyindex c3b40bd0c..67307fd2f 100644--- a/catalog/tests/templates/test_create_provider_ingester.py+++ b/catalog/tests/templates/test_create_provider_ingester.py@@ -49,7 +49,7 @@ def test_sanitize_provider(provider, expected_result):def test_files_created(tmp_path):- # Make temporary output directorys for testing+ # Make temporary output directories for testingdags_path = tmp_path / "catalog" / "dags" / "providers"(dags_path / "provider_api_scripts").mkdir(parents=True)test_path = tmp_path / "catalog" / "tests"diff --git a/documentation/changelogs/api/2023.05.15.21.51.49.md b/documentation/changelogs/api/2023.05.15.21.51.49.mdindex 7d2dd234e..46c3d5450 100644--- a/documentation/changelogs/api/2023.05.15.21.51.49.md+++ b/documentation/changelogs/api/2023.05.15.21.51.49.md@@ -25,7 +25,7 @@([#2075](https://github.com/WordPress/openverse/pull/2075)) by @dhruvkb- Remove unused and empty settings file([#2069](https://github.com/WordPress/openverse/pull/2069)) by @dhruvkb-- Add throttle classess for health check endpoint+- Add throttle classes for health check endpoint([#2061](https://github.com/WordPress/openverse/pull/2061)) by @krysal- Simplify and reorder parameters to `catalog/pgcli` recipe([#2023](https://github.com/WordPress/openverse/pull/2023)) by @AetherUnbounddiff --git a/documentation/changelogs/frontend/2023.07.28.23.42.26.md b/documentation/changelogs/frontend/2023.07.28.23.42.26.mdindex c5745a918..ef3a1b3bc 100644--- a/documentation/changelogs/frontend/2023.07.28.23.42.26.md+++ b/documentation/changelogs/frontend/2023.07.28.23.42.26.md@@ -9,7 +9,7 @@## Improvements-- Add test/ to .dockerignore to exlcude tests and test assets from frontend+- Add test/ to .dockerignore to exclude tests and test assets from frontendimage build context([#2713](https://github.com/WordPress/openverse/pull/2713)) by @sehgxl- Update the Box image and Large image cell component hover statediff --git a/documentation/frontend/reference/testing_guidelines.md b/documentation/frontend/reference/testing_guidelines.mdindex c1e8b850c..59d4d5ae0 100644--- a/documentation/frontend/reference/testing_guidelines.md+++ b/documentation/frontend/reference/testing_guidelines.md@@ -16,7 +16,7 @@ deployed to production) you can find the staging deployment here:https://staging.openverse.org-Staging is redeployed everytime we merge to the `main` branch, so if you're+Staging is redeployed every time we merge to the `main` branch, so if you'relooking to test the latest version of the app without going through the localset up, that's the easiest way to go.diff --git a/documentation/general/deployment.md b/documentation/general/deployment.mdindex d365650fa..9125bf2b9 100644--- a/documentation/general/deployment.md+++ b/documentation/general/deployment.md@@ -203,7 +203,7 @@ it. Please see theTerraform configuration)2. Deploy the code that depends on the new or updated variable by dispatching- the appropriate deployment workflow for the application and envionment that+ the appropriate deployment workflow for the application and environment thatwas updated.- If the application only needs to be re-deployed to the alreadyrunning-version, dispatch the workflow with the version present at thediff --git a/documentation/general/zero_downtime_database_management.md b/documentation/general/zero_downtime_database_management.mdindex f2d6c7083..72ee6fbc5 100644--- a/documentation/general/zero_downtime_database_management.md+++ b/documentation/general/zero_downtime_database_management.md@@ -306,7 +306,7 @@ be aware of.In order to understand the potential issues that can arise in managingenvironment variables, it is necessary to first understand the mechanisms used-to management them and how they are propogated to application instances.+to management them and how they are propagated to application instances.Environment variables for applications and their environments are configured andmanaged in the _task definition template_. The ECS service for each applicationdiff --git a/documentation/meta/ci_cd/proof_of_functionality.md b/documentation/meta/ci_cd/proof_of_functionality.mdindex aa8e388f5..f37d30f6f 100644--- a/documentation/meta/ci_cd/proof_of_functionality.md+++ b/documentation/meta/ci_cd/proof_of_functionality.md@@ -23,7 +23,7 @@ proof-of-functionality for different use-cases.### Catalog-The tests for the catalog in `test-cat` are very comprehensive and rigourous,+The tests for the catalog in `test-cat` are very comprehensive and rigorous,including extended test suites using the `--extended` flag. Passing these testsconclusively proves that the catalog works as intended.diff --git a/documentation/meta/codespell.md b/documentation/meta/codespell.mdnew file mode 100644index 000000000..0c8edb6fa--- /dev/null+++ b/documentation/meta/codespell.md@@ -0,0 +1,85 @@+# Codespell Configuration : spellcheck pre-commit hook++The main codespell configuration lives in the root directory's+[`pyproject.toml`](https://github.com/WordPress/openverse/tree/main/pyproject.toml).+Because the `skip` configuration variable does not support TOML arrays, in order+to make the configured skip directories and files more readable and+maintainable, they are configured as arguments to the command. However,+codespell configuration also relies on a variety of special, individual files to+configure ignores and special words. Those files are contained in this directory+in order to avoid increasing the number of random configuration files in the+project root. Each file is described below and uses a `.txt` extension to+disambiguate format.++Most of these files support arbitrary lines used as comments. For the sake of+convention, these lines should be prefixed with `;;` to designate a comment as+opposed to a `#`. `;;` is used because it is not significant in any of the+languages or configuration files we use, and it is thus extremely unlikely to+cause a false-positive.++## Limitations++Be aware of the following codespell limitations:++- Case-sensitive corrections are not available:+ https://github.com/codespell-project/codespell/pull/1880++## `ignore_lines.txt`++[`ignore_lines.txt`](https://github.com/WordPress/openverse/tree/main/.codespell/ignore_words.txt)+is used to configure the following setting:++```+ -x FILE, --exclude-file FILE+ ignore whole lines that match those in the file FILE. The lines in FILE should match the to-be-excluded lines exactly+```++Pay special attention to the format of this file. Each line of the file must+match the target line to ignore _exactly_. In other words, if a line has leading+whitespace, that whitespace must be included. For example, if we need to ignore+the last line of the following:++```yaml+jobs:+ steps:+ - name: amazing step+ with:+ misspelled-action-argment: hello world!!!!!+```++The line in `ignore_lines.txt` must include all eight of the leading whitespace+characters to ignore the misspelled action argument. The following will not+work:++```+misspelled-action-argment: hello world!!!!!+```++It must be:++```+ misspelled-action-argment: hello world!!!!!+```++When documenting ignored lines, please include an explanation and the targeted+filename.++## `ignore_words.txt`++[`ignore_words.txt`](https://github.com/WordPress/openverse/tree/main/.codespell/ignore_words.txt)+is used to configure the following setting:++```+ -I FILE, --ignore-words FILE+ file that contains words that will be ignored by codespell. File must contain 1 word per line. Words are case sensitive based on how they are written in the dictionary file+```++Despite the fact that codespell does not match misspelled words+case-sensitively, the words in this file must match the dictionary case. For+example, codespell will complain that the common `afterAll` Jest hook function+name should be changed to `after all`. The relevant dictionary entry is+`afterall->after all`. Therefore, the ignore words file must read `afterall`,+not `afterAll`.++Codespell's dictionaries can be found here:+https://github.com/codespell-project/codespell/tree/master/codespell_lib/data.diff --git a/documentation/meta/decision_making/additional_practices.md b/documentation/meta/decision_making/additional_practices.mdindex 524a05126..a379da528 100644--- a/documentation/meta/decision_making/additional_practices.md+++ b/documentation/meta/decision_making/additional_practices.md@@ -112,7 +112,7 @@ can follow two processes:discussions and halting other, smaller, often technical discussions.2. Split the group into groups of three or four people who can participate indifferent parts of the discussion. This is useful if there are multiple- time-sensitive discussions and could lead to synchronous "lightening process"+ time-sensitive discussions and could lead to synchronous "lightning process"meetings to make faster decisions and reduce the ongoing discussion burden onteam members. Even in this case, limit to 1 ongoing team-wide processdiscussion per group of contributors. This is less useful if everyone on the@@ -155,4 +155,4 @@ can be broken into two separate sections to allow time for revision.Even in these cases, however, the text of the proposal should still be writtenin a GitHub PR or discussion and available for all participants to read _before_-the lightening process.+the lightning process.diff --git a/documentation/meta/documentation/review.md b/documentation/meta/documentation/review.mdindex ed8059f60..2d91aefb9 100644--- a/documentation/meta/documentation/review.md+++ b/documentation/meta/documentation/review.md@@ -1,6 +1,6 @@# Documentation proofreading and review-Historically the Openverse project has occassionally done a "documentation bug+Historically the Openverse project has occasionally done a "documentation bugbash" where maintainers sat down together to read through our existingdocumentation and identify potential issues or necessary changes. While thisshould happen in a concerted, maintainer-wide effort at least once a year, wediff --git a/documentation/meta/index.md b/documentation/meta/index.mdindex 46192c980..cff028528 100644--- a/documentation/meta/index.md+++ b/documentation/meta/index.md@@ -11,4 +11,5 @@ decision_making/indexdocumentation/indexmonitoring/indexcommunication_aliases+codespell```diff --git a/documentation/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.md b/documentation/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.mdindex f804b4aec..810e976be 100644--- a/documentation/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.md+++ b/documentation/meta/monitoring/traffic/runbooks/identifying-and-blocking-traffic-anomalies.md@@ -57,7 +57,7 @@ single best way to mitigate malicious traffic.Expectations about the ratio of traffic a single source should occupy are basedon historical data and subject to change over time. To validate these baselinepercentages, please analyze a time-slice of traffic *without* any known-malicious traffic, if one exists in Cloudflare's avaliable data, checking for+malicious traffic, if one exists in Cloudflare's available data, checking forany single source exceeding the percentages listed here.```diff --git a/documentation/packages/index.md b/documentation/packages/index.mdindex c60ba5771..f6b404ff8 100644--- a/documentation/packages/index.md+++ b/documentation/packages/index.md@@ -1,8 +1,8 @@# Node.js packagesOpenverse uses `pnpm` workspaces to facilitate collecting multiple Node.js-projects into a single repository. This section documents the individual packges-and how to add/maintain them.+projects into a single repository. This section documents the individual+packages and how to add/maintain them.```{toctree}:titlesonly:diff --git a/documentation/projects/planning.md b/documentation/projects/planning.mdindex b3a90e453..13cb17516 100644--- a/documentation/projects/planning.md+++ b/documentation/projects/planning.md@@ -248,7 +248,7 @@ steps should be organised into parallelisable work streams that can bedistributed across multiple team members (if desired).Implementation plans share some philosophical goals with project plans. They-should seek to uncover and discover new or unforseen details about a project.+should seek to uncover and discover new or unforeseen details about a project.#### Required contentdiff --git a/documentation/projects/proposals/analytics/20221006-implementation_plan_frontend.md b/documentation/projects/proposals/analytics/20221006-implementation_plan_frontend.mdindex 5d26c9966..43691530a 100644--- a/documentation/projects/proposals/analytics/20221006-implementation_plan_frontend.md+++ b/documentation/projects/proposals/analytics/20221006-implementation_plan_frontend.md@@ -69,7 +69,7 @@ analytics system.## The technical detailsWe will create a system for collecting events on the frontend. Each event will-have a unique name, collect some default data about the enviroment (timestamp,+have a unique name, collect some default data about the environment (timestamp,referer, and so on) and can have an optional data payload containing string andnumerical values. I'd like to limit the payload shape to strings and numbers tokeep it JSON serializable and simple. Allowing for complex nested objects might@@ -486,7 +486,7 @@ async function sendEvent<T extends AnalyticsEventTypes>(}/*** Actually send the event here, with some additional values.- * I would have prefered to use `navigator.sendBeacon` here+ * I would have preferred to use `navigator.sendBeacon` here* but it is blocked by most ad blockers.** We might not want to call our api route "analytics" to@@ -553,8 +553,8 @@ data. This is about as robust as an open-source user behavior tracking platformcan be.[Plausible](https://plausible.io/) is a simple, lightweight, and self-hostable-Google Analytics alternative. Our implementation here would be easily-compatiable with Plausible's self-hosted or cloud offerings.+Google Analytics alternative. Our implementation here would be easily compatible+with Plausible's self-hosted or cloud offerings.[Umami](https://umami.is/) is quite similar to Plausible. Their codebasecontainsdiff --git a/documentation/projects/proposals/monitoring/20220307-project_proposal.md b/documentation/projects/proposals/monitoring/20220307-project_proposal.mdindex 328f88faa..64a8f3fe1 100644--- a/documentation/projects/proposals/monitoring/20220307-project_proposal.md+++ b/documentation/projects/proposals/monitoring/20220307-project_proposal.md@@ -65,7 +65,7 @@ metric from over the last 5 minutes, or any other span of time). It includesanomaly detection as well as integration with many tools you can use foralerting like Slack, PagerDuty, or email. There are[official and unofficial client libraries](https://prometheus.io/docs/instrumenting/clientlibs/)-for all the langauges we currently use or could conceivably use in the future+for all the languages we currently use or could conceivably use in the futureincluding Python, Node.js, Go, PHP, and JVM languages.Grafana is a data visualization tool that supports building complex dashboards.@@ -156,8 +156,8 @@ up-front that we can anticipate wanting monitors for.- Sustained periods of time (60 seconds?) where`count_req_total == count_5xx_total` or`count_req_total >= (count_5xx_total / threshold)`- - Note, queries are rarely that intutive to write and have at least two moving- parts that dictate how the alarm works, the query and then the alarm+ - Note, queries are rarely that intuitive to write and have at least two+ moving parts that dictate how the alarm works, the query and then the alarmcondition.- Each view has a version of the above relative to request frequency. Views withlower overall requests per second will require longer windows of time before@@ -375,7 +375,7 @@ stack between local and production. This will mostly involve passing environmentvariables to Grafana and Prometheus to configure them for production.Aside from service configuration, however, there is also the issue of how to-store our Prometheus query, alerting, and other configuations locally. Likewise+store our Prometheus query, alerting, and other configurations locally. Likewisewe need to address that for Grafana dashboards. For example, we don't want tohave to manually copy the configurations for our anomaly monitors fromproduction. Even if we develop these monitors in a live staging environment@@ -515,7 +515,7 @@ contents of this PR.- Use a new, small RDS instance for Grafana's Postgres DB.- Rely on Prometheus primarily as a metrics aggregator and time series database.Do not use it for rule and alarm configuration.-- Rely on Grafana for visbility and alarming upstream from Prometheus.+- Rely on Grafana for visibility and alarming upstream from Prometheus.- Create separate alarm streams per service in Mailman and aggregate all alarmsinto a Slack channel for extra visibility and redundancy.- Use `django-prometheus` library to add the Prometheus `/metrics` endpoint to@@ -543,7 +543,7 @@ contents of this PR.new endpoint.1. Create the same `/metrics` endpoint for Nuxt using the[Node.js client library](https://github.com/siimon/prom-client)- - This will be more work as we'll have to write our own middlware for it.+ - This will be more work as we'll have to write our own middleware for it.- There are some existing Nuxt Prometheus modules like[this one](https://github.com/franckaragao/nuxt-prometheus-module) butthey're not maintained and far more basic than what we actually want to@@ -636,7 +636,7 @@ know).Graphite is also older than Prometheus and while it works really well, there's alot less current information about how to deploy and configure it. There's also-almost no support for languages outside of the core langauges supported by the+almost no support for languages outside of the core languages supported by theproject including poor JavaScript support (which would make monitoring our Nuxtservice more difficult).diff --git a/documentation/projects/proposals/popularity_optimizations/20230406-project_proposal_popularity_optimizations.md b/documentation/projects/proposals/popularity_optimizations/20230406-project_proposal_popularity_optimizations.mdindex fc74152dd..fcfaf93cb 100644--- a/documentation/projects/proposals/popularity_optimizations/20230406-project_proposal_popularity_optimizations.md+++ b/documentation/projects/proposals/popularity_optimizations/20230406-project_proposal_popularity_optimizations.md@@ -34,7 +34,7 @@ following criteria:1. A full data refresh should reliably complete in less than one week, for eachmedia type.2. During a data refresh, all updates made to existing records since the- previous refesh should propagate to the API DB and Elasticsearch.+ previous refresh should propagate to the API DB and Elasticsearch.3. During a data refresh, all _new_ records ingested since the previous refreshshould propagate to the API DB and Elasticsearch.4. Records for providers that support popularity metrics should havediff --git a/documentation/projects/proposals/search_relevancy_sandbox/20230406-implementation_plan_update_staging_database.md b/documentation/projects/proposals/search_relevancy_sandbox/20230406-implementation_plan_update_staging_database.mdindex d09daf479..943dd5a7b 100644--- a/documentation/projects/proposals/search_relevancy_sandbox/20230406-implementation_plan_update_staging_database.md+++ b/documentation/projects/proposals/search_relevancy_sandbox/20230406-implementation_plan_update_staging_database.md@@ -227,7 +227,7 @@ namely:3. Foreign Data Wrapper to insert all records from production media tables intostaging-We opted to defer the persuit of this alternate approach for the time being for+We opted to defer the pursuit of this alternate approach for the time being forthe following reasons:- The FDW/replication approach(es) described may have numerous pitfalls,diff --git a/documentation/projects/proposals/search_relevancy_sandbox/20230518-implementation_plan_staging_index_rapid_iteration.md b/documentation/projects/proposals/search_relevancy_sandbox/20230518-implementation_plan_staging_index_rapid_iteration.mdindex 730db7147..b9fa6b7e5 100644--- a/documentation/projects/proposals/search_relevancy_sandbox/20230518-implementation_plan_staging_index_rapid_iteration.md+++ b/documentation/projects/proposals/search_relevancy_sandbox/20230518-implementation_plan_staging_index_rapid_iteration.md@@ -357,7 +357,7 @@ There are no external blockers to this project.<!-- Explore or mention any changes to the API versioning scheme. -->-No API verison changes should be necessary.+No API version changes should be necessary.## Accessibilitydiff --git a/documentation/projects/proposals/search_relevancy_sandbox/20230530-implementation_plan_staging_elasticsearch_reindex_dags.md b/documentation/projects/proposals/search_relevancy_sandbox/20230530-implementation_plan_staging_elasticsearch_reindex_dags.mdindex 9117ea3a4..e4b930f86 100644--- a/documentation/projects/proposals/search_relevancy_sandbox/20230530-implementation_plan_staging_elasticsearch_reindex_dags.md+++ b/documentation/projects/proposals/search_relevancy_sandbox/20230530-implementation_plan_staging_elasticsearch_reindex_dags.md@@ -208,7 +208,7 @@ creation of different indexes, which is the end goal of the project.### Combining DAGs for custom index creation into one-During the discussion of this plan the idea of potencially combining the+During the discussion of this plan the idea of potentially combining the`create_proportional_by_provider_<media_type>_staging_index` DAG or both DAGsdefined here with the one described in the plan to[create indexes with custom configurations](/projects/proposals/search_relevancy_sandbox/20230530-implementation_plan_staging_elasticsearch_reindex_dags.md).diff --git a/documentation/projects/proposals/trust_and_safety/20230109-trust_and_safety_preliminary_overview_and_exploration.md b/documentation/projects/proposals/trust_and_safety/20230109-trust_and_safety_preliminary_overview_and_exploration.mdindex ad37518fe..612ebb6df 100644--- a/documentation/projects/proposals/trust_and_safety/20230109-trust_and_safety_preliminary_overview_and_exploration.md+++ b/documentation/projects/proposals/trust_and_safety/20230109-trust_and_safety_preliminary_overview_and_exploration.md@@ -277,7 +277,7 @@ possible, both for visual and textual material.query hashes. Needed to be able to easily bust cached pages to exclude theresult.- Query hashes should be reversible (as in, we can derive the query parameters- from the hash or we maintain a mapping of hash -> query paramters) so that+ from the hash or we maintain a mapping of hash -> query parameters) so thatwe can bust caches for a query hash- The HTTP cache for relevant searches and single results (currentlyCloudflare) are automatically updated when a result is removeddiff --git a/documentation/projects/proposals/trust_and_safety/content_report_moderation/20230411-project_proposal_content_report_moderation.md b/documentation/projects/proposals/trust_and_safety/content_report_moderation/20230411-project_proposal_content_report_moderation.mdindex 93202dedf..fb6324941 100644--- a/documentation/projects/proposals/trust_and_safety/content_report_moderation/20230411-project_proposal_content_report_moderation.md+++ b/documentation/projects/proposals/trust_and_safety/content_report_moderation/20230411-project_proposal_content_report_moderation.md@@ -250,7 +250,7 @@ This change to API cache management does not necessarily entirely preclude the u#### Redis based cache invalidation strategyIn order to invalidate search query responses that include a certain result, we-need to maintain a reverse index of `result indentifier -> cache keys`. When a+need to maintain a reverse index of `result identifier -> cache keys`. When agiven result is marked as sensitive or deindexed due to a report, we need tobust the cached responses for the keys stored under that result's identifier.Cache keys also need to be invalidated based on the response cache timeout.diff --git a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-implementation_plan_sensitive_terms_list.md b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-implementation_plan_sensitive_terms_list.mdindex cf3d27a82..ee4f2506e 100644--- a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-implementation_plan_sensitive_terms_list.md+++ b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-implementation_plan_sensitive_terms_list.md@@ -76,7 +76,7 @@ reports to find identify new terms are users are being exposed to inadvertently.1. Why is the list in a standalone repository, instead of thehttps://github.com/wordPress/openverse?- The main reason to keep the list seperate is contributor safety. The list is+ The main reason to keep the list separate is contributor safety. The list iskept independently from the codebase so that users must explicitly consentto viewing and downloading it. Additionally, there are Search EngineOptimization and blocklist considerations with public GitHub repositories.@@ -92,7 +92,7 @@ reports to find identify new terms are users are being exposed to inadvertently.The vast majority of indexed works are in English. Additionally, it would bedifficult to validate suggestions for terms in languages not spoken byOpenverse maintainers, which to my current knowledge includes English,- Spanish, Brazilian Portugese, Turkish, and Russian. English is the only+ Spanish, Brazilian Portuguese, Turkish, and Russian. English is the onlylanguage used by all maintainers.3. On what basis will Openverse maintainers use their "discretion" to creatediff --git a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-project_proposal_detecting_sensitive_textual_content.md b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-project_proposal_detecting_sensitive_textual_content.mdindex 248d630f5..1198b0b26 100644--- a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-project_proposal_detecting_sensitive_textual_content.md+++ b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230309-project_proposal_detecting_sensitive_textual_content.md@@ -17,7 +17,7 @@ textual content are determined, blur those results on the frontend.> textual context. That inference applies specifically to the textual content> _only_, but is also likely to apply to content itself (whether image or> audio). We also acknowledge the various pit-falls that can come with this-> approach as well as its insufficency. However, it's the best approach we can+> approach as well as its insufficiency. However, it's the best approach we can> implement now, in a timely manner, that will substantively improve the> accessibility of Openverse.diff --git a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230330-implementation_plan_filtering_and_designating_results_with_sensitive_textual_content.md b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230330-implementation_plan_filtering_and_designating_results_with_sensitive_textual_content.mdindex d97d99c54..2d23c30eb 100644--- a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230330-implementation_plan_filtering_and_designating_results_with_sensitive_textual_content.md+++ b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230330-implementation_plan_filtering_and_designating_results_with_sensitive_textual_content.md@@ -405,7 +405,7 @@ result_ids = set({r["_id"] for r in results})results_in_filtered_index = query_filtered_index(results_ids)ids_in_filtered_index = set({r["_id"] for r in results_in_filtered_index})-# Use set arithmatic to derive the list of sensitive documents+# Use set arithmetic to derive the list of sensitive documentssensitive_text_result_ids = result_ids - ids_in_filtered_index```diff --git a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230506-implementation_plan_frontend_blurring_sensitive.md b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230506-implementation_plan_frontend_blurring_sensitive.mdindex 0037b5c4f..d535ef26d 100644--- a/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230506-implementation_plan_frontend_blurring_sensitive.md+++ b/documentation/projects/proposals/trust_and_safety/detecting_sensitive_textual_content/20230506-implementation_plan_frontend_blurring_sensitive.md@@ -67,7 +67,7 @@ developed.- Content safety wall- Hide content button-- Additonal pages+- Additional pages- Sensitivity documentation pagediff --git a/frontend/src/constants/key-codes.ts b/frontend/src/constants/key-codes.tsindex 91e0cf089..b32290bb6 100644--- a/frontend/src/constants/key-codes.ts+++ b/frontend/src/constants/key-codes.ts@@ -6,7 +6,7 @@* needed just add it.** This mostly exists to avoid having to look at the MDN page- * everytime you need to look up a keycode, especially for easy+ * every time you need to look up a keycode, especially for easy* to forget ones like Spacebar, while also removing "magic strings".*/diff --git a/frontend/src/server-middleware/healthcheck.js b/frontend/src/server-middleware/healthcheck.jsindex 6e3927593..674b4f8cc 100644--- a/frontend/src/server-middleware/healthcheck.js+++ b/frontend/src/server-middleware/healthcheck.js@@ -2,7 +2,7 @@* A simple healthcheck that is always true.** @todo Update to a resource-sensitive version that fails when- * memory and/or cpu usage reach a configurable threshhold.+ * memory and/or cpu usage reach a configurable threshold.* @type {import('@nuxt/types').ServerMiddleware}*/export default function healthcheck(_, res) {diff --git a/frontend/test/playwright/utils/navigation.ts b/frontend/test/playwright/utils/navigation.tsindex 99f0e1ea0..04ce549c5 100644--- a/frontend/test/playwright/utils/navigation.ts+++ b/frontend/test/playwright/utils/navigation.ts@@ -363,7 +363,7 @@ export const getLocatorHref = async (locator: Locator) => {* - the `window`, on interior pages* - the `#main-page`, on search views*- * This is necessary because on search views the window itself doesnt scroll, only+ * This is necessary because on search views the window itself does not scroll, only* its child elements (the search result area + the filter sidebar).** This function will scroll both elements on every evocation.diff --git a/frontend/test/unit/specs/utils/decode-data.spec.js b/frontend/test/unit/specs/utils/decode-data.spec.jsindex 9451058fe..36d7ddaa8 100644--- a/frontend/test/unit/specs/utils/decode-data.spec.js+++ b/frontend/test/unit/specs/utils/decode-data.spec.js@@ -37,7 +37,7 @@ describe("decodeData", () => {expect(decodeData(data)).toBe("musée")})- it("shouldnt throw exception", () => {+ it("shouldn't throw exception", () => {const data = "Classic Twill - SlipcoverFabrics.com 100% Cotton"expect(decodeData(data)).toBe(data)diff --git a/frontend/test/unit/specs/utils/prepare-search-query-params.spec.js b/frontend/test/unit/specs/utils/prepare-search-query-params.spec.jsindex 8ff7e1318..e551adc3c 100644--- a/frontend/test/unit/specs/utils/prepare-search-query-params.spec.js+++ b/frontend/test/unit/specs/utils/prepare-search-query-params.spec.js@@ -33,7 +33,7 @@ describe("prepareSearchQueryParams", () => {expect(result.tags).toBe("foo")})- it("doesnt remove q key when searchBy value is empty", () => {+ it("does not remove q key when searchBy value is empty", () => {const params = {q: "foo",searchBy: [],diff --git a/frontend/test/unit/test-utils/api-service-mock.ts b/frontend/test/unit/test-utils/api-service-mock.tsindex c0d8a49db..3f4d548ef 100644--- a/frontend/test/unit/test-utils/api-service-mock.ts+++ b/frontend/test/unit/test-utils/api-service-mock.ts@@ -11,7 +11,7 @@ const createApiService = apiService.createApiService as jest.Mock<>/**- * Creates an API Serivce that get's reused throughout the lifetime of+ * Creates an API Service that gets reused throughout the lifetime of* the current context in which it is called.** @example@@ -40,7 +40,7 @@ const createApiService = apiService.createApiService as jest.Mock<* With the particual way this mock creation function works,* even if `createApiService` is called several times during* the lifecycle of a particular test context, the same `apiService`- * instace will be reused for each call. This is done to preserve+ * instance will be reused for each call. This is done to preserve* lists of responses applied to the mock adapter in the `applyMocks`* callback. Otherwise, if `createApiService` is called more than* once per test, then each time it is called will cause a newdiff --git a/justfile b/justfileindex dc1e16329..f3f222346 100644--- a/justfile+++ b/justfile@@ -202,7 +202,7 @@ node-recreate:logs services="" args=(if IS_CI != "" { "" } else { "-f" }):just dc logs {{ args }} {{ services }}-# Attach to the specificed service to interacting with its TTY+# Attach to the specified service to interacting with its TTYattach service:docker attach $(just dc ps | awk '{print $1}' | grep {{ service }})diff --git a/pyproject.toml b/pyproject.tomlnew file mode 100644index 000000000..1e5844932--- /dev/null+++ b/pyproject.toml@@ -0,0 +1,45 @@+# TOML configuration for tools that support it should be placed in this file+# We do not use pyproject.toml to describe build requirements. This file+# should only be referenced for tool configuration, not build settings!++[tool.codespell]+exclude-file = ".codespell/ignore_lines.txt"+ignore-words = ".codespell/ignore_words.txt"++[tool.ruff.per-file-ignores]+"*test*" = ["E501"]+"*__init__*" = ["F401"]+"*wsgi.py" = ["E402"]+"*settings/__init__.py" = ["F403"]++[tool.isort]+profile = "black"++sections = [+ "FUTURE",+ "STDLIB",+ "DJANGO",+ "THIRDPARTY",+ "FIRSTPARTY",+ "LOCALFOLDER",+]++known_django = [+ "django",+ "rest_framework",+]++known_first_party = [+ "conf",+ "api",+ "ingestion_server",+ "common",+ "data_refresh",+ "database",+ "maintenance",+ "oauth2",+ "providers",+ "retired",+]++lines_after_imports = 2diff --git a/utilities/dead_links/dead_link_tally.py b/utilities/dead_links/dead_link_tally.pyindex 9136ee392..1a1d9cda4 100644--- a/utilities/dead_links/dead_link_tally.py+++ b/utilities/dead_links/dead_link_tally.py@@ -1,5 +1,5 @@"""-Retrives dead link tallies from Openverse API Redis.+Retrieves dead link tallies from Openverse API Redis.This script assumes that the API Redis instance you care about is presenton localhost (usually via tunneling). It will run through the link validationdiff --git a/utilities/provider_tallies/README.md b/utilities/provider_tallies/README.mdindex ce9b422fb..34401fc37 100644--- a/utilities/provider_tallies/README.md+++ b/utilities/provider_tallies/README.md@@ -15,5 +15,5 @@ By default, the script will output the results to `provider_tally_stats.csv` inthe current directory. Use the `--output` flag to specify a different outputfile.-This script can also be used to extract information acquired _after_ a certian+This script can also be used to extract information acquired _after_ a certaindate. Use the `--start-date` flag to specify a date in the format `YYYY-MM-DD`.