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 #19

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

yarikoptic
Copy link

@yarikoptic yarikoptic commented Nov 21, 2024

More about codespell: https://github.com/codespell-project/codespell .

I personally introduced it to dozens if not hundreds of projects already and so far only positive feedback.

CI workflow has 'permissions' set only to 'read' so also should be safe.

TODOs

  • remove TEMP commit and possible github workflow if pre-commit picks up the typo somewhere inCI

…agically

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
Copy link
Collaborator

@marshallmcdonnell marshallmcdonnell left a comment

Choose a reason for hiding this comment

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

Overall, LGTM!

I have one small change request that just looks like an accident but overall, thanks for the contribution!

Pinging @Lance-Drane since I am happy to approve but would like his review of CI + pre-commit before merge.

README.md Outdated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Probably just an accident but lost the README.

Maybe a quick git checkout main -- README.md or git checkout origin/main -- README.md (for remote) should fix that!

Copy link
Author

Choose a reason for hiding this comment

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

dang, rushed it up... redid last commit

echo "lenght" >> README*; git commit -m 'TEMP: adding typo to see if pre-commit also picks it up' -a

so we get that typo in -- wanted to see if your CI already runs pre-commit since then I would just remove dedicated codespell workflow.

overall - that TEMP commit would be gone before I take it out of the draft

Copy link
Collaborator

Choose a reason for hiding this comment

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

so we get that typo in -- wanted to see if your CI already runs pre-commit since then I would just remove dedicated codespell workflow.

Our current CI/CD pipeline doesn't run our pre-commit hooks but I was thinking that this may be a good idea, do you happen to know of any repositories which have a modern pre-commit workflow? I did some reading around and found:

I think that the CI/CD workflow in this MR is fine and I'd like to accept it as you currently have it, I'm mostly just curious.

Copy link
Author

Choose a reason for hiding this comment

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

I saw both a pre-commit action (even with push back of changes, e.g. making codespell -w) and using pre-commit.ci . I have no first hand experience with either of those frankly . I am ok to leave original dedicated action in as well -- I kinda like it that way because

  • immediately can see which particular aspect is broken
  • runs fast
  • should annotate where typo is using that codespell-project/codespell-problem-matcher@v1 but I do not see it annotated here :-/ I will remove typo TEMP commit now to get a clean run though

@Lance-Drane
Copy link
Collaborator

Thank you for the contribution! I think that this will be a useful addition, particularly since it's catching several documentation and Exception spelling errors. (It's pretty funny that I made the same spelling error in both an Exception and a test checking the Exception message.) The only thing I think is necessary would be to get rid of the test commit, I'm happy to approve otherwise.

I don't mind doing this myself if you're not familiar with PDM, but I'd like to add it as a PDM development dependency under the "lint" group (pdm add --dev -G lint codespell) and make sure it's reflected in the lockfile.

@@ -132,7 +132,7 @@ class PydanticUnparsableInner:
three: str

@intersect_message()
def cant_parse_annotation(self, unparseable: PydanticUnparsableInner) -> None: ...
def cant_parse_annotation(self, unparsable: PydanticUnparsableInner) -> None: ...
Copy link
Collaborator

@Lance-Drane Lance-Drane Nov 21, 2024

Choose a reason for hiding this comment

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

In the assertion statement of this test on line 140, we'll need to change parameter 'unparseable' to parameter 'unparsable' to make sure it passes the test. I think this is the only reason the tests are failing.

Copy link
Author

Choose a reason for hiding this comment

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

ha -- thanks for catching. I didn't know about this nuance! Apparently codespell, while determining words, includes ' as part of the word.

Proposed

and now digging deeper there :-(

@Lance-Drane
Copy link
Collaborator

It looks like the CI pipeline works, BTW:

https://github.com/INTERSECT-SDK/python-sdk/actions/runs/11957237005/job/33336619928?pr=19

In case it isn't visible:

2024-11-21_12-17

codespell from codespell-project/codespell#3588

=== Do not change lines below ===
{
 "chain": [],
 "cmd": "codespell -w ./tests/unit/test_schema_invalids.py",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
@yarikoptic yarikoptic marked this pull request as ready for review November 22, 2024 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants