Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Unify pre-commit config across repos (#330)
Dhruv Bhanushali50d4d6825ec7
diff --git a/automations/.flake8 b/.flake8similarity index 100%rename from automations/.flake8rename to .flake8diff --git a/.github/sync.yml b/.github/sync.ymlindex bf98f991e..7e12d887f 100644--- a/.github/sync.yml+++ b/.github/sync.yml@@ -33,10 +33,17 @@ group:# Downstream workflows- source: .github/workflows_downstream/draft_release.ymldest: .github/workflows/draft_release.yml+ # Templates- source: .github/release_drafter.ymldest: .github/release_drafter.yml- # Templates- source: .github/ISSUE_TEMPLATE/dest: .github/ISSUE_TEMPLATE/- source: .github/PULL_REQUEST_TEMPLATE.mddest: .github/PULL_REQUEST_TEMPLATE.md+ # Unified lint rules+ - repos: |+ WordPress/openverse-catalog+ WordPress/openverse-api+ files:+ - source: .pre-commit-config.yaml+ dest: .pre-commit-config.yamldiff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 075366628..770cb4bc2 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -1,4 +1,4 @@-exclude: Pipfile\.lock|migrations|\.idea|node_modules+exclude: Pipfile\.lock|migrations|\.idea|node_modules|archiverepos:- repo: https://github.com/pre-commit/pre-commit-hooks@@ -6,6 +6,7 @@ repos:hooks:- id: trailing-whitespaceargs: [--markdown-linebreak-ext=md]+ - id: check-docstring-first- id: check-executables-have-shebangs- id: check-json- id: check-case-conflict@@ -40,12 +41,17 @@ repos:- --ensure-newline-before-comments- --line-length=88+ - repo: https://github.com/asottile/pyupgrade+ rev: v3.2.2+ hooks:+ - id: pyupgrade+ args:+ - --py310-plus+- repo: https://github.com/PyCQA/flake8rev: 3.9.2hooks:- id: flake8- args:- - --config=automations/.flake8- repo: https://github.com/ambv/blackrev: 22.3.0diff --git a/automations/python/label_pr.py b/automations/python/label_pr.pyindex 8055b169d..25c8576c5 100644--- a/automations/python/label_pr.py+++ b/automations/python/label_pr.py@@ -6,7 +6,6 @@ import loggingimport osimport refrom http.cookiejar import CookieJar-from typing import Optionalimport mechanizeimport pyotp@@ -134,7 +133,7 @@ def get_linked_issues(url: str) -> list[str]:return [a["href"] for a in form.find_all("a")]-def get_label_of_cat(cat: str, labels: list[Label]) -> Optional[Label]:+def get_label_of_cat(cat: str, labels: list[Label]) -> Label | None:"""Get the label of a particular category from the given list of labels.diff --git a/automations/python/shared/data.py b/automations/python/shared/data.pyindex 65f43cb82..c982389b3 100644--- a/automations/python/shared/data.py+++ b/automations/python/shared/data.py@@ -23,4 +23,4 @@ def get_data(file_name: str) -> dict:data_file: str = str(ROOT_DIR.joinpath("data", file_name))log.info(f"Reading file {data_file}")- return yaml.safe_load(open(data_file, "r"))+ return yaml.safe_load(open(data_file))diff --git a/automations/python/shared/github.py b/automations/python/shared/github.pyindex 8e9da70e4..d7889cff9 100644--- a/automations/python/shared/github.py+++ b/automations/python/shared/github.py@@ -1,6 +1,5 @@import loggingimport os-import typingfrom github import Github@@ -19,7 +18,7 @@ def get_client(is_authenticated: bool = True) -> Github:log.info("Setting up GitHub client")if is_authenticated:- access_token: typing.Optional[str] = os.getenv("ACCESS_TOKEN")+ access_token: str | None = os.getenv("ACCESS_TOKEN")if access_token is None:log.error("Access token was not found in env.ACCESS_TOKEN.")raise ValueError("Access token not found")