Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #37

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within pyproject.toml
---
name: Codespell
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a strong reason for this to be its own workflow rather than folded into ci.yaml?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be done so if you like but

  • you have already lots of commands in there sequentially and without separate steps -- so one fails (e.g. black) and others already don't run, and here you just see that CI failed but do not know what check exactly
  • why don't you use pre-commit and instead list individual calls there? (related: fresh "Address" detected by pre-commit issues #40). Could be done via action or there is even pre-commit service IIRC (I typically do not use it but other projects do)
  • having separate workflow or parametrization for it shows up as a separate report here in PR so makes it easier to immediately see what is wrong. They also then run in parallel

With that in mind I would have recommended to move "pre-commit" encoded checks into separate workflow, and leave/rename ci to run only tests but across different python versions (now just 3.8)

You could also encode them all in a single CI workflow file, but then I would also recommend to centralize them actually outside, e.g. in tox.ini and then just sweep through different invocations. Eg. look at https://github.com/con/duct/blob/main/.github/workflows/test.yaml which sweeps through different pythons for testing but also adds runs for type checks and linting.

so -- many ways to skin a cat here ;-)


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: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the codespell-problem-matcher necessary? What does it do on top of the basic codespell action?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it annotates typos directly in the PR diff - quite handy

- name: Codespell
uses: codespell-project/actions-codespell@v2
8 changes: 8 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ repos:
rev: v1.2.0
hooks:
- id: mypy

- repo: https://github.com/codespell-project/codespell
# Configuration for codespell is in pyproject.toml
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
[MESSAGES CONTROL]

# Only show warnings with the listed confidence levels. Leave empty to show
# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED

Check failure on line 35 in .pylintrc

View workflow job for this annotation

GitHub Actions / Check for spelling errors

EFINED ==> DEFINED, REFINED
confidence=

# Enable the message, report, category or checker with the given id(s). You can
Expand All @@ -45,7 +45,7 @@
# can either give multiple identifiers separated by comma (,) or put this
# option multiple times (only on the command line, not in the configuration
# file where it should appear only once).You can also use "--disable=all" to
# disable everything first and then reenable specific checks. For example, if
# disable everything first and then re-enable specific checks. For example, if
# you want to run only the similarities checker, you can use "--disable=all
# --enable=similarities". If you want to run only the classes checker, but have
# no Warning level messages displayed, use"--disable=all --enable=classes
Expand Down
8 changes: 4 additions & 4 deletions bids2table/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def to_path(
int_format: str = "%d",
) -> Path:
"""
Generate a filepath based on the entitities.
Generate a filepath based on the entities.
"""
special = {"datatype", "suffix", "ext"}
data = self.to_dict(valid_only=valid_only)
Expand All @@ -210,14 +210,14 @@ def to_path(
return path

def with_update(
self, entitities: Optional[Dict[str, Any]] = None, **kwargs
self, entities: Optional[Dict[str, Any]] = None, **kwargs
) -> Self:
"""
Create a new instance with updated entities.
"""
data = self.to_dict(valid_only=False)
if entitities:
data.update(entitities)
if entities:
data.update(entities)
if kwargs:
data.update(kwargs)
return self.__class__.from_dict(data)
Expand Down
2 changes: 1 addition & 1 deletion example/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -3629,7 +3629,7 @@
"source": [
"## Using the command-line interface\n",
"\n",
"bids2table comes with a command-line iterface `bids2table` (alias `b2t`). Check out the help message."
"bids2table comes with a command-line interface `bids2table` (alias `b2t`). Check out the help message."
]
},
{
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,10 @@ log_cli_level = "DEBUG"
[tool.mypy]
no_strict_optional = true
ignore_missing_imports = true

[tool.codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = '.git*'
check-hidden = true
ignore-regex = '(^\s*"image/\S+": ".*|ND)'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are here to suppress false positives? We will see how long this gets 😅.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed ND to be a complete word now, that is what tripped CI. For the ipynb included images -- quite a reliable pattern , wouldn't expect problems.

# ignore-words-list = ''
Loading