From 2d0f900d5a460d3c68942fb48a53245e1f8e1211 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 13 Feb 2024 12:24:36 -0500 Subject: [PATCH] Add codespell configuration, workflow, pre-commit config and fix few typos (#1842) * Add github action to codespell main on push and PRs Signed-off-by: Yaroslav Halchenko * Add rudimentary codespell config Signed-off-by: Yaroslav Halchenko * Add pre-commit definition for codespell Signed-off-by: Yaroslav Halchenko * skip tests and dotfiles for codespell Signed-off-by: Yaroslav Halchenko * [DATALAD RUNCMD] run codespell throughout fixing typo automagically === Do not change lines below === { "chain": [], "cmd": "codespell -w", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^ Signed-off-by: Yaroslav Halchenko * Fix spells * Fix config * pre-commit: exclude tests --------- Signed-off-by: Yaroslav Halchenko Co-authored-by: Koudai Aono --- .github/workflows/codespell.yml | 23 +++++++++++++++++++ .pre-commit-config.yaml | 8 +++++++ README.md | 2 +- datamodel_code_generator/__init__.py | 2 +- docs/index.md | 2 +- pyproject.toml | 7 ++++++ .../main/main_graphql_github_api/output.py | 2 +- .../main/main_openapi_http_refs/output.py | 2 +- tests/data/graphql/github-api.graphql | 18 +++++++-------- tests/data/openapi/definitions.yaml | 2 +- tests/data/openapi/query_parameters.yaml | 2 +- 11 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 00000000..dd0eb8e5 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,23 @@ +# Codespell configuration is within pyproject.toml +--- +name: Codespell + +on: + push: + branches: [main] + pull_request: + branches: [main] + +permissions: + contents: read + +jobs: + codespell: + name: Check for spelling errors + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Codespell + uses: codespell-project/actions-codespell@v2 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ad4990d9..4e529741 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,3 +9,11 @@ repos: - id: ruff-format files: "^datamodel_code_generator|^tests" exclude: "^tests/data" + - repo: https://github.com/codespell-project/codespell + # Configuration for codespell is in pyproject.toml + rev: v2.2.6 + hooks: + - id: codespell + additional_dependencies: + - tomli + exclude: "^tests/" diff --git a/README.md b/README.md index 83542aff..17ee97e9 100644 --- a/README.md +++ b/README.md @@ -422,7 +422,7 @@ Model customization: --enable-version-header Enable package version on file headers --keep-model-order Keep generated models' order - --reuse-model Re-use models on the field when a module has the model + --reuse-model Reuse models on the field when a module has the model with the same content --target-python-version {3.6,3.7,3.8,3.9,3.10,3.11} target python version (default: 3.7) diff --git a/datamodel_code_generator/__init__.py b/datamodel_code_generator/__init__.py index 9df843f7..aaa3e177 100644 --- a/datamodel_code_generator/__init__.py +++ b/datamodel_code_generator/__init__.py @@ -525,7 +525,7 @@ def infer_input_type(text: str) -> InputFileType: inferred_message = ( - 'The input file type was determined to be: {}\nThis can be specificied explicitly with the ' + 'The input file type was determined to be: {}\nThis can be specified explicitly with the ' '`--input-file-type` option.' ) diff --git a/docs/index.md b/docs/index.md index d89aed00..008fb01b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -419,7 +419,7 @@ Model customization: --enable-version-header Enable package version on file headers --keep-model-order Keep generated models' order - --reuse-model Re-use models on the field when a module has the model + --reuse-model Reuse models on the field when a module has the model with the same content --target-python-version {3.6,3.7,3.8,3.9,3.10,3.11} target python version (default: 3.7) diff --git a/pyproject.toml b/pyproject.toml index 7e10ae5d..b877bd26 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -153,3 +153,10 @@ ignore-init-method-arguments = true [tool.pydantic-pycharm-plugin.parsable-types] # str field may parse int and float str = ["int", "float"] + +[tool.codespell] +# Ref: https://github.com/codespell-project/codespell#using-a-config-file +skip = '.git,*.lock,tests' +# check-hidden = true +# ignore-regex = '' +# ignore-words-list = '' diff --git a/tests/data/expected/main/main_graphql_github_api/output.py b/tests/data/expected/main/main_graphql_github_api/output.py index 98b5cdb4..a21c842c 100644 --- a/tests/data/expected/main/main_graphql_github_api/output.py +++ b/tests/data/expected/main/main_graphql_github_api/output.py @@ -23107,7 +23107,7 @@ Reactor: TypeAlias = Union[ ] -# Any referencable object +# Any referenceable object ReferencedSubject: TypeAlias = Union[ 'Issue', 'PullRequest', diff --git a/tests/data/expected/main/main_openapi_http_refs/output.py b/tests/data/expected/main/main_openapi_http_refs/output.py index 4eeed3e1..c960e3a2 100644 --- a/tests/data/expected/main/main_openapi_http_refs/output.py +++ b/tests/data/expected/main/main_openapi_http_refs/output.py @@ -12,7 +12,7 @@ from pydantic import AnyUrl, BaseModel, Field, conint class Problem(BaseModel): detail: Optional[str] = Field( None, - description='A human readable explanation specific to this occurrence of the\nproblem. You MUST NOT expose internal informations, personal\ndata or implementation details through this field.\n', + description='A human readable explanation specific to this occurrence of the\nproblem. You MUST NOT expose internal information, personal\ndata or implementation details through this field.\n', example='Request took too long to complete.', ) instance: Optional[AnyUrl] = Field( diff --git a/tests/data/graphql/github-api.graphql b/tests/data/graphql/github-api.graphql index 2da3572f..ed84cd40 100644 --- a/tests/data/graphql/github-api.graphql +++ b/tests/data/graphql/github-api.graphql @@ -3398,7 +3398,7 @@ input CheckRunFilter { conclusions: [CheckConclusionState!] """ - Filters the check runs by this status. Superceded by statuses. + Filters the check runs by this status. Superseded by statuses. """ status: CheckStatusState @@ -12265,14 +12265,14 @@ input EnablePullRequestAutoMergeInput { clientMutationId: String """ - Commit body to use for the commit when the PR is mergable; if omitted, a + Commit body to use for the commit when the PR is mergeable; if omitted, a default message will be used. NOTE: when merging with a merge queue any input value for commit message is ignored. """ commitBody: String """ - Commit headline to use for the commit when the PR is mergable; if omitted, a + Commit headline to use for the commit when the PR is mergeable; if omitted, a default message will be used. NOTE: when merging with a merge queue any input value for commit headline is ignored. """ @@ -20934,7 +20934,7 @@ type MergeQueueConfiguration { minimumEntriesToMerge: Int """ - The amount of time in minutes to wait before ignoring the minumum number of + The amount of time in minutes to wait before ignoring the minimum number of entries in the queue requirement and merging a collection of entries """ minimumEntriesToMergeWaitTime: Int @@ -21085,7 +21085,7 @@ enum MergeQueueMergingStrategy { ALLGREEN """ - Failing Entires are allowed to merge if they are with a passing entry. + Failing Entries are allowed to merge if they are with a passing entry. """ HEADGREEN } @@ -33912,7 +33912,7 @@ The possible roles of a collaborator on a project. """ enum ProjectV2Roles { """ - The collaborator can view, edit, and maange the settings of the project + The collaborator can view, edit, and manage the settings of the project """ ADMIN @@ -39277,7 +39277,7 @@ type ReferencedEvent implements Node { } """ -Any referencable object +Any referenceable object """ union ReferencedSubject = Issue | PullRequest @@ -54687,12 +54687,12 @@ enum ThreadSubscriptionState { IGNORING_THREAD """ - The User is not recieving notifications from this thread + The User is not receiving notifications from this thread """ NONE """ - The User is notified becuase they are watching the list + The User is notified because they are watching the list """ SUBSCRIBED_TO_LIST diff --git a/tests/data/openapi/definitions.yaml b/tests/data/openapi/definitions.yaml index 2e99635d..d326c027 100644 --- a/tests/data/openapi/definitions.yaml +++ b/tests/data/openapi/definitions.yaml @@ -5,7 +5,7 @@ schemas: detail: description: | A human readable explanation specific to this occurrence of the - problem. You MUST NOT expose internal informations, personal + problem. You MUST NOT expose internal information, personal data or implementation details through this field. example: Request took too long to complete. type: string diff --git a/tests/data/openapi/query_parameters.yaml b/tests/data/openapi/query_parameters.yaml index 235b6256..9c9ee3fe 100644 --- a/tests/data/openapi/query_parameters.yaml +++ b/tests/data/openapi/query_parameters.yaml @@ -100,7 +100,7 @@ paths: items: $ref: "#/components/schemas/Pet" '500': - description: An internal error occured + description: An internal error occurred content: application/json: schema: