Skip to content

"Interaction" with pre-commit: ideally should skip the skipped files. #3196

Open

Description

@yarikoptic

I ran into it before but forgot to report, and now didn't find open issue. Currently inspired by PrefectHQ/prefect#10893 where running codespell in CLI directly results in no hits, but pre-commit reports:

codespell................................................................Failed
- hook id: codespell
- exit code: 65

.github/ISSUE_TEMPLATE/5_maintenance_ticket.yaml:1: maintenence ==> maintenance
.github/workflows/python-tests.yaml:62: automaticlly ==> automatically
.github/workflows/python-tests.yaml:246: automaticlly ==> automatically
.github/ISSUE_TEMPLATE/2_ui_bug_report.yaml:69: Browers ==> Browsers
ui/package-lock.json:2999: OT ==> TO, OF, OR, NOT
ui/package-lock.json:8411: OT ==> TO, OF, OR, NOT
src/prefect/_vendor/fastapi/utils.py:131: unecessary ==> unnecessary

Problems:

  1. If I define files to skip in codespell configuration (e.g. in .codespellrc), those files will not be skipped in pre-commit run --all since ( I guess) pre-commit would pass those paths explicitly to codespell invocation and thus it would not account for skip.

  2. Also, complimentary, may be codespell should check in .dotdirs like .github etc?

Activity

  1. DimitriPapadopoulos commented on Nov 3, 2023

    @DimitriPapadopoulos
    Collaborator
    1. It looks like we do skip explicitly passed files that match the skip list:
      $ echo unecessary > foobar
      $ 
      $ codespell foobar
      foobar:1: unecessary ==> unnecessary
      $ 
      $ codespell -S foobar foobar
      $ 
      
      Could it be that .codespellrc is not taken into account when codespell is run by pre-commit?
    2. Does option -H/--check-hidden help?
  2. yarikoptic commented on Nov 3, 2023

    @yarikoptic
    ContributorAuthor
    1. Could it be that .codespellrc is not taken into account when codespell is run by pre-commit?

    I think it might be more of the case of directories listed in skip

    ❯ grep skip .codespellrc
    skip = .git,*.pdf,*.svg,versioneer.py,package-lock.json,_vendor,*.css
    ❯ codespell
    ❯ codespell **/_vendor
    src/prefect/_vendor/fastapi/utils.py:131: unecessary ==> unnecessary

    2. Does option -H/--check-hidden help?

    oh, it does! besides that I need to skip .codespellrc explicitly then. I should probably make this "default" in my "codespellit" script.

  3. DimitriPapadopoulos commented on Nov 3, 2023

    @DimitriPapadopoulos
    Collaborator

    oh, it does! besides that I need to skip .codespellrc explicitly then. I should probably make this "default" in my "codespellit" script.

    Mmmh.. I wonder whether we should always skip files named .codespellrc.

  4. DimitriPapadopoulos commented on Nov 3, 2023

    @DimitriPapadopoulos
    Collaborator
    ❯ grep skip .codespellrc
    skip = .git,*.pdf,*.svg,versioneer.py,package-lock.json,_vendor,*.css
    ❯ codespell
    ❯ codespell src
    ❯ codespell src/prefect
    ❯ codespell src/prefect/_vendor
    src/prefect/_vendor/fastapi/utils.py:131: unecessary ==> unnecessary
    ❯ codespell src/prefect/_vendor/fastapi
    src/prefect/_vendor/fastapi/utils.py:131: unecessary ==> unnecessary
    

    It looks like we don't test well enough the root directory passed as an argument.

  5. yarikoptic commented on Nov 28, 2023

    @yarikoptic
    ContributorAuthor

    FWIW, if I have missed the point above -- seems to apply also for target filename, not just folder:

    ❯ codespell community/front-end/ofe/
    ❯ codespell community/front-end/
    ❯ codespell community/
    ❯ codespell
    ❯ codespell --version
    2.2.6
    ❯ pre-commit run --all codespell
    codespell................................................................Failed
    - hook id: codespell
    - exit code: 65
    
    community/front-end/ofe/requirements.txt:4: astroid ==> asteroid
    community/front-end/ofe/website/ghpcfe/static/js/bootstrap.bundle.js:2947: trough ==> through
    community/front-end/ofe/website/ghpcfe/static/js/bootstrap.bundle.js:3420: othwerise ==> otherwise
    community/front-end/ofe/website/ghpcfe/static/js/bootstrap.bundle.js:3842: ofset ==> offset, of set
    community/front-end/ofe/website/ghpcfe/static/js/bootstrap.bundle.js:3873: trough ==> through
    community/front-end/ofe/website/ghpcfe/static/js/jquery.formset.js:166: thnaks ==> thanks
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:2176: guarnteed ==> guaranteed
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:6353: enhancments ==> enhancements
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:6521: enhancment ==> enhancement
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:7308: multipe ==> multiple
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8018: Deffered ==> Differed, Deferred
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8827: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8918: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8920: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8923: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8925: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8927: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8930: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8932: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8945: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8956: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8988: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8995: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:8997: calender ==> calendar
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:9493: overriden ==> overridden
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:10468: modfied ==> modified
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:12226: openening ==> opening
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:13972: inital ==> initial
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:16590: get's ==> gets
    community/front-end/ofe/website/ghpcfe/static/js/jquery-ui.js:17906: durning ==> during
    
    ❯ grep skip .codespellrc
    skip = .git,*.pdf,*.svg,*.min.js,*.js.map,js,requirements.txt
    
  6. added a commit that references this issue on Nov 28, 2023
  7. yarikoptic commented on Jan 22, 2024

    @yarikoptic
    ContributorAuthor

    ping on this issue -- any hope to get it addressed soon? need help?

  8. DimitriPapadopoulos commented on Jan 23, 2024

    @DimitriPapadopoulos
    Collaborator

    I think this one is tougher than it seems.

    Suppose we have this setup:

    a
    └── b
        └── c
            └── file.txt
    

    If the skip list contains b/c, it should work with all of:

    codespell -S b/c a
    codespell -S b/c a/b
    codespell -S b/c a/b/c
    codespell -S b/c a/b/c/file.txt
    

    Perhaps all cases are not relevant with pre-commit, but they should be addressed nevertheless.

    To properly work under Windows, the path separator may need to be normalised.

    Also should paths be normalised?

    codespell -S b/c a/b/c/../../another_dir/another_file.txt
    
  9. yarikoptic commented on Jan 23, 2024

    @yarikoptic
    ContributorAuthor

    Also should paths be normalised?

    yeah, probably since otherwise no way for all path components consideration, but then I think only the relative to CWD should be taken since otherwise the full path could contain it e.g. /home/mine/a/b/some/project/do/not/skip/me

  10. DimitriPapadopoulos commented on Jan 24, 2024

    @DimitriPapadopoulos
    Collaborator

    It depends on how pre-commit calls codespell. Paths relative to CWD or absolute paths?

  11. yarikoptic commented on Jan 25, 2024

    @yarikoptic
    ContributorAuthor

    while at it (in django-rest-framework)

    protocol from a single invocation of `pre-commit run --all -v codespell`
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/reverse.py', 'mkdocs.yml', 'tests/test_htmlrenderer.py', 'rest_framework/templates/rest_framework/inline/dict_field.html', 'rest_framework/templates/rest_framework/vertical/form.html', 'tests/test_negotiation.py', 'tests/test_settings.py', 'docs/tutorial/quickstart.md', 'rest_framework/templates/rest_framework/raw_data_form.html', 'docs/api-guide/fields.md', 'docs/tutorial/4-authentication-and-permissions.md', 'rest_framework/templates/rest_framework/admin.html', 'docs/topics/documenting-your-api.md', 'tests/test_validation_error.py', 'rest_framework/templates/rest_framework/filters/base.html', 'rest_framework/settings.py', 'docs_theme/css/default.css', 'tests/browsable_api/auth_urls.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/checks.py', 'docs/api-guide/settings.md', 'rest_framework/templates/rest_framework/horizontal/fieldset.html', 'docs/community/funding.md', 'rest_framework/schemas/openapi.py', 'rest_framework/templates/rest_framework/horizontal/dict_field.html', 'tests/test_relations_slug.py', 'rest_framework/templates/rest_framework/horizontal/radio.html', 'tests/schemas/test_openapi.py', 'docs/community/3.1-announcement.md', 'rest_framework/views.py', 'rest_framework/templates/rest_framework/admin/detail.html', 'rest_framework/parsers.py', 'rest_framework/utils/timezone.py', 'rest_framework/authtoken/views.py', 'rest_framework/documentation.py', 'rest_framework/static/rest_framework/css/prettify.css', 'docs/tutorial/3-class-based-views.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/response.py', 'tests/schemas/test_managementcommand.py', 'tests/generic_relations/__init__.py', 'rest_framework/utils/field_mapping.py', 'rest_framework/static/rest_framework/js/bootstrap.min.js', 'rest_framework/authtoken/migrations/0003_tokenproxy.py', 'tests/test_serializer_bulk_update.py', 'docs/api-guide/views.md', 'tests/test_one_to_one_with_inheritance.py', 'rest_framework/templatetags/rest_framework.py', 'PULL_REQUEST_TEMPLATE.md', 'rest_framework/utils/representation.py', 'rest_framework/templates/rest_framework/inline/textarea.html', 'docs/topics/internationalization.md', 'rest_framework/templates/rest_framework/inline/checkbox.html', 'tests/test_renderers.py', 'rest_framework/static/rest_framework/js/csrf.js', 'tests/utils.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'docs/api-guide/validators.md', 'docs/community/project-management.md', 'rest_framework/templates/rest_framework/inline/input.html', 'rest_framework/templates/rest_framework/vertical/radio.html', 'rest_framework/urls.py', 'tests/test_decorators.py', 'tests/test_reverse.py', 'tests/browsable_api/no_auth_urls.py', 'docs_theme/nav.html', 'rest_framework/templates/rest_framework/inline/radio.html', 'rest_framework/permissions.py', 'docs/api-guide/pagination.md', 'docs/community/3.0-announcement.md', 'docs/index.md', 'rest_framework/templates/rest_framework/horizontal/select_multiple.html', 'rest_framework/templates/rest_framework/horizontal/form.html', 'tests/test_description.py', 'docs/community/3.6-announcement.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/static/rest_framework/css/bootstrap-theme.min.css.map', 'rest_framework/static/rest_framework/js/prettify-min.js', 'requirements.txt', 'rest_framework/templates/rest_framework/horizontal/select.html', 'docs/api-guide/content-negotiation.md', 'rest_framework/templates/rest_framework/horizontal/list_fieldset.html', 'rest_framework/templates/rest_framework/admin/list.html', 'rest_framework/templates/rest_framework/vertical/select_multiple.html', 'tests/test_metadata.py', 'setup.py', 'rest_framework/decorators.py', 'rest_framework/management/commands/generateschema.py', 'rest_framework/templates/rest_framework/docs/langs/shell.html', 'rest_framework/static/rest_framework/css/bootstrap.min.css.map', 'tests/test_templatetags.py', 'docs/api-guide/exceptions.md', 'docs/api-guide/filtering.md', 'rest_framework/static/rest_framework/js/ajax-form.js']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/templates/rest_framework/docs/langs/javascript.html', 'docs_theme/css/prettify.css', 'rest_framework/templates/rest_framework/docs/auth/basic.html', 'rest_framework/templates/rest_framework/docs/index.html', 'rest_framework/templates/rest_framework/base.html', 'tests/test_atomic_requests.py', 'tests/authentication/migrations/__init__.py', 'rest_framework/throttling.py', 'docs/community/jobs.md', 'rest_framework/utils/humanize_datetime.py', 'tests/browsable_api/views.py', 'rest_framework/authtoken/migrations/__init__.py', 'rest_framework/utils/urls.py', 'rest_framework/templates/rest_framework/horizontal/textarea.html', '.github/workflows/codespell.yml', 'rest_framework/static/rest_framework/js/default.js', 'rest_framework/templates/rest_framework/docs/langs/shell-intro.html', 'docs/community/3.3-announcement.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'setup.cfg', 'tests/browsable_api/test_browsable_nested_api.py', 'rest_framework/validators.py', 'docs/community/3.13-announcement.md', 'rest_framework/templates/rest_framework/docs/sidebar.html', 'rest_framework/templates/rest_framework/inline/select_multiple.html', 'licenses/bootstrap.md', 'tests/test_templates.py', 'rest_framework/generics.py', 'docs/community/3.2-announcement.md', 'requirements/requirements-documentation.txt', 'rest_framework/templates/rest_framework/vertical/list_fieldset.html', 'rest_framework/templates/rest_framework/vertical/fieldset.html', 'rest_framework/serializers.py', 'rest_framework/authtoken/management/commands/__init__.py', 'requirements/requirements-optionals.txt', 'tests/schemas/test_get_schema_view.py', 'docs/api-guide/responses.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', '.pre-commit-config.yaml', 'rest_framework/templates/rest_framework/vertical/checkbox.html', 'MANIFEST.in', 'tests/test_throttling.py', 'rest_framework/authtoken/migrations/0004_alter_tokenproxy_options.py', '.github/stale.yml', 'tests/test_status.py', 'tests/test_relations.py', 'docs_theme/js/jquery-1.8.1-min.js', '.github/ISSUE_TEMPLATE/1-issue.md', 'docs/community/3.10-announcement.md', 'rest_framework/static/rest_framework/docs/css/highlight.css', 'rest_framework/authtoken/__init__.py', 'rest_framework/static/rest_framework/js/load-ajax-form.js', 'docs/api-guide/relations.md', 'docs/tutorial/1-serialization.md', 'rest_framework/static/rest_framework/fonts/fontawesome-webfont.svg', 'tests/test_multitable_inheritance.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'codecov.yml', 'SECURITY.md', 'tests/test_requests_client.py', 'rest_framework/authtoken/admin.py', 'rest_framework/authtoken/apps.py', 'rest_framework/utils/__init__.py', 'tests/test_permissions.py', '.github/ISSUE_TEMPLATE/config.yml', 'rest_framework/status.py', 'docs/api-guide/renderers.md', 'LICENSE.md', 'docs/CNAME', 'rest_framework/authtoken/management/commands/drf_create_token.py', 'rest_framework/static/rest_framework/css/bootstrap-theme.min.css', 'rest_framework/templates/rest_framework/vertical/dict_field.html', 'tests/generic_relations/test_generic_relations.py', 'tests/test_utils.py', 'tests/test_urlpatterns.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/schemas/generators.py', 'docs/topics/browsable-api.md', 'rest_framework/utils/serializer_helpers.py', '.github/workflows/main.yml', 'tests/test_fields.py', 'rest_framework/routers.py', 'rest_framework/templates/rest_framework/docs/interact.html', 'tox.ini', 'rest_framework/templates/rest_framework/inline/checkbox_multiple.html', 'docs/api-guide/format-suffixes.md', 'rest_framework/templates/rest_framework/login_base.html', 'tests/test_api_client.py', 'rest_framework/relations.py', 'tests/test_validation.py', 'tests/test_viewsets.py', 'tests/generic_relations/migrations/0001_initial.py', 'tests/test_middleware.py', 'tests/test_versioning.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'docs/community/3.8-announcement.md', 'tests/browsable_api/test_browsable_api.py', 'docs/api-guide/viewsets.md', 'tests/models.py', 'docs/api-guide/testing.md', 'rest_framework/static/rest_framework/css/default.css', 'docs/community/mozilla-grant.md', 'tests/test_response.py', 'rest_framework/templates/rest_framework/login.html', 'docs/community/3.12-announcement.md', 'rest_framework/static/rest_framework/docs/css/jquery.json-view.min.css', 'rest_framework/filters.py', '.gitignore', 'docs/community/3.4-announcement.md', 'rest_framework/schemas/views.py', 'rest_framework/templates/rest_framework/admin/dict_value.html', 'rest_framework/templates/rest_framework/vertical/checkbox_multiple.html', 'rest_framework/templates/rest_framework/schema.js']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/templates/rest_framework/inline/list_fieldset.html', 'rest_framework/templates/rest_framework/docs/langs/python-intro.html', 'rest_framework/templates/rest_framework/inline/fieldset.html', 'tests/__init__.py', 'docs/api-guide/parsers.md', 'tests/test_authtoken.py', 'rest_framework/static/rest_framework/docs/css/base.css', 'rest_framework/renderers.py', 'rest_framework/apps.py', 'rest_framework/templates/rest_framework/docs/langs/javascript-intro.html', 'rest_framework/fields.py', 'docs/community/3.7-announcement.md', 'tests/test_model_serializer.py', 'rest_framework/templates/rest_framework/vertical/list_field.html', 'docs/community/contributing.md', 'docs/community/3.14-announcement.md', 'docs/api-guide/serializers.md', 'tests/test_relations_pk.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/request.py', 'docs/api-guide/generic-views.md', 'rest_framework/templates/rest_framework/admin/list_value.html', 'docs/api-guide/caching.md', 'rest_framework/templates/rest_framework/admin/simple_list_value.html', 'rest_framework/exceptions.py', 'rest_framework/urlpatterns.py', 'rest_framework/templates/rest_framework/filters/ordering.html', 'rest_framework/static/rest_framework/docs/js/jquery.json-view.min.js', 'tests/test_testing.py', 'rest_framework/templates/rest_framework/docs/auth/token.html', 'docs/api-guide/reverse.md', 'rest_framework/static/rest_framework/js/jquery-3.7.1.min.js', 'rest_framework/templates/rest_framework/horizontal/checkbox_multiple.html', 'rest_framework/metadata.py', 'docs/api-guide/throttling.md', 'requirements/requirements-testing.txt', 'rest_framework/templates/rest_framework/inline/list_field.html']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'tests/authentication/models.py', 'rest_framework/mixins.py', '.codespellrc', 'tests/browsable_api/test_form_rendering.py', 'docs/api-guide/requests.md', 'rest_framework/templates/rest_framework/api.html', 'rest_framework/templates/rest_framework/docs/link.html', 'docs/api-guide/schemas.md', 'rest_framework/authtoken/migrations/0002_auto_20160226_1747.py', '.github/FUNDING.yml', 'docs_theme/css/bootstrap-responsive.css', 'rest_framework/utils/encoders.py', 'requirements/requirements-packaging.txt', 'rest_framework/utils/model_meta.py', 'rest_framework/authtoken/management/__init__.py', 'docs/api-guide/permissions.md', '.tx/config', 'tests/conftest.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'tests/schemas/views.py', 'docs/topics/ajax-csrf-cors.md', 'rest_framework/utils/mediatypes.py', 'rest_framework/viewsets.py', 'rest_framework/utils/json.py', 'docs_theme/js/prettify-1.0.js', 'rest_framework/authtoken/models.py', 'runtests.py', 'rest_framework/static/rest_framework/docs/js/api.js', 'tests/test_serializer_lists.py', 'docs/api-guide/routers.md', 'docs/community/3.5-announcement.md', 'tests/test_routers.py', 'tests/test_relations_hyperlink.py', 'tests/browsable_api/serializers.py', 'rest_framework/static/rest_framework/css/bootstrap-tweaks.css', 'rest_framework/templates/rest_framework/inline/select.html', 'docs/community/3.9-announcement.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/templates/rest_framework/docs/document.html', 'docs/tutorial/2-requests-and-responses.md', 'tests/test_lazy_hyperlinks.py', 'rest_framework/authtoken/migrations/0001_initial.py', 'docs_theme/main.html', 'tests/urls.py', 'docs/api-guide/authentication.md', 'rest_framework/schemas/inspectors.py', 'rest_framework/templates/rest_framework/horizontal/checkbox.html', 'tests/authentication/__init__.py', 'rest_framework/templates/rest_framework/horizontal/list_field.html', 'rest_framework/templates/rest_framework/docs/error.html', 'docs_theme/js/bootstrap-2.1.1-min.js', 'README.md', 'tests/test_exceptions.py', 'tests/schemas/test_coreapi.py', 'tests/importable/__init__.py', 'tests/test_views.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'rest_framework/static/rest_framework/css/bootstrap.min.css', 'tests/authentication/migrations/0001_initial.py', 'docs_theme/js/theme.js', 'rest_framework/authentication.py', 'tests/generic_relations/migrations/__init__.py', 'rest_framework/utils/breadcrumbs.py', 'rest_framework/pagination.py', 'rest_framework/templates/rest_framework/docs/langs/python.html', 'tests/browsable_api/__init__.py', 'rest_framework/templates/rest_framework/vertical/input.html', 'rest_framework/static/rest_framework/docs/js/highlight.pack.js', 'docs/topics/rest-hypermedia-hateoas.md', '.github/workflows/pre-commit.yml', 'rest_framework/schemas/__init__.py', 'tests/test_validators.py', 'rest_framework/compat.py', 'licenses/jquery.json-view.md', 'rest_framework/utils/html.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'tests/test_request.py', 'docs/topics/browser-enhancements.md', 'rest_framework/templates/rest_framework/pagination/previous_and_next.html', 'rest_framework/management/commands/__init__.py', 'docs_theme/404.html', 'tests/test_serializer_nested.py', 'docs/topics/writable-nested-serializers.md', 'rest_framework/templates/rest_framework/pagination/numbers.html', 'rest_framework/versioning.py', 'docs_theme/css/bootstrap.css', 'docs/community/3.11-announcement.md', 'CONTRIBUTING.md', 'tests/test_parsers.py', 'rest_framework/templatetags/__init__.py', 'rest_framework/negotiation.py', 'rest_framework/templates/rest_framework/inline/form.html', 'tests/test_prefetch_related.py', 'docs/community/release-notes.md']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'docs/api-guide/metadata.md', 'docs/community/third-party-packages.md', 'docs/tutorial/6-viewsets-and-routers.md', 'rest_framework/management/__init__.py', 'rest_framework/schemas/coreapi.py', 'docs/topics/html-and-forms.md', 'tests/test_write_only_fields.py', 'tests/test_encoders.py', 'docs/tutorial/5-relationships-and-hyperlinked-apis.md', 'tests/test_filters.py', 'rest_framework/templates/rest_framework/filters/search.html', 'rest_framework/utils/formatting.py', 'tests/test_bound_fields.py', 'rest_framework/templates/rest_framework/docs/auth/session.html', 'tests/generic_relations/models.py', 'rest_framework/templates/rest_framework/vertical/select.html', 'rest_framework/schemas/utils.py', 'tests/schemas/__init__.py']
    codespell argv: ['/home/yoh/.cache/pre-commit/repo_g5kpzb_/py_env-python3/bin/codespell', 'docs/api-guide/status-codes.md', 'docs/api-guide/versioning.md', 'rest_framework/templates/rest_framework/horizontal/input.html', 'tests/test_pagination.py', 'docs/community/tutorials-and-resources.md', 'tests/authentication/test_authentication.py', 'rest_framework/authtoken/serializers.py', 'rest_framework/test.py', 'tests/test_serializer.py', 'rest_framework/static/rest_framework/fonts/glyphicons-halflings-regular.svg', 'rest_framework/static/rest_framework/css/font-awesome-4.0.3.css', 'rest_framework/__init__.py', 'tests/test_generics.py', 'rest_framework/templates/rest_framework/vertical/textarea.html', 'tests/importable/test_installed.py']
    

    and the same when I run from subfolder. So - relative paths. I even did modification of a single file within subfolder and invoked within subfolder -- got relative path from the top

  12. yarikoptic commented on Oct 28, 2024

    @yarikoptic
    ContributorAuthor

    ping on this issue. keep running into it.

  13. added a commit that references this issue on Sep 1, 2025
  14. added a commit that references this issue on Sep 2, 2025
  15. chuenchen309 commented on Jul 17, 2026

    @chuenchen309

    Ran into this from a different angle and went looking for the mechanism, since the thread has the symptom well characterised but I couldn't find the line responsible written down anywhere. It's a plain asymmetry between the two branches of the file loop in _codespell.py.

    The walk branch (os.path.isdir(filename)) tests the skip glob four times:

    line test catches
    :1500 glob_match.match(root) absolute directory path
    :1509 glob_match.match(file_) basename
    :1512 glob_match.match(fname) full path
    :1531 dirs[:] = [... if not glob_match.match(dir_)] relative directory

    The explicit-file branch tests it once, against the literal argument string:

    elif not glob_match.match(filename):  # :1538

    So skip = _vendor is matched against src/prefect/_vendor/fastapi/utils.py as a whole string, fails, and the file is checked. Same skip list, same file — the answer depends only on whether the path arrived via os.walk or via argv.

    Reproducer, same tree and same typo both times:

    $ codespell --skip="./src/3rdParty" .
    ./src/app/main.py:1: teh ==> the                       # vendor.py correctly skipped
    
    $ codespell --skip="./src/3rdParty" ./src/3rdParty/vendor.py ./src/app/main.py
    ./src/3rdParty/vendor.py:1: teh ==> the                # <-- not skipped
    ./src/app/main.py:1: teh ==> the
    

    A basename pattern behaves the same way — --skip=vendor.py . skips it, --skip=vendor.py ./src/3rdParty/vendor.py doesn't. That's the :1509 check having no counterpart in the explicit branch.

    This is also why it shows up as a pre-commit problem specifically: .pre-commit-hooks.yaml here is entry: codespell with types: [text], and pre-commit always passes explicit filenames, so the hook takes the one-check branch every time. Nothing about .codespellrc loading — the config is read fine, it just isn't applied to the same things.

    On @DimitriPapadopoulos's "If the skip list contains b/c, it should work with all of..." and @yarikoptic's "should paths be normalised?" — I think those are still the live questions, and they're the reason I'm not opening a PR. Making the explicit branch match basenames and ancestors would start skipping files that someone who typed an explicit path may well expect to be checked, and "an explicit argument overrides the filters" is a defensible position that ripgrep and black both take. So it's a behaviour decision rather than a missing line.

    If it's useful, the shapes I can see are:

    1. Mirror the walk branch — check basename and each ancestor directory of the explicit path. Fixes pre-commit; changes behaviour for anyone relying on explicit paths winning.
    2. Ancestors only, not basename — narrower; addresses the skip = _vendor / directory case from the original report without touching the --skip=*.js style.
    3. Leave it, document it — say plainly in the README and --help that --skip applies to traversal, and point pre-commit users at exclude: in .pre-commit-config.yaml instead.

    Existing tests don't pin any of this either way: test_ignore covers basename (--skip=bad.txt) and bare directory names, but every case goes through tmp_path, i.e. the walk branch. The one explicit-file case (--skip=*.js) only passes because the leading * happens to absorb the whole path under fnmatch.

    Happy to put up whichever of the three you'd want — just don't want to guess at the semantics on a two-year-old thread where the question was already raised and not settled.

    (Disclosure: AI-assisted. The reproducer, the line-by-line comparison of the two branches, and the test-coverage check are all things I ran and read rather than assumed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions