-
Notifications
You must be signed in to change notification settings - Fork 33
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
feat: add pre-commit hooks and format existing code #100
Conversation
7ced223
to
f9b0d84
Compare
This commit introduces pre-commit hooks to ensure that Python and Rust code adheres to the specified style guidelines and quality standards. The following hooks have been added to the .pre-commit-config.yaml file: - pre-commit-hooks: - trailing-whitespace: Removes trailing whitespace - end-of-file-fixer: Ensures files end with a newline - check-yaml: Validates YAML files - check-json: Validates JSON files - check-added-large-files: Prevents large files from being added - check-merge-conflict: Detects merge conflict markers - black: - Formats Python code according to Black's style guide with a max line length of 120 characters - flake8: - Lints Python code with Flake8 and flake8-bugbear plugin, ignoring F401 errors and allowing a max line length of 120 characters - Mypy: - Performs static type checking on Python code, ignoring missing imports with --ignore-missing-imports flag - local: - cargo fmt: Formats Rust code using These hooks will run automatically before each commit, helping to maintain a consistent code style and quality across the project. Additionally, this commit reformats the current codebase to comply with the new style guidelines enforced by the pre-commit hooks. BREAKING CHANGE: Developers must now have pre-commit installed and configured to contribute to the project.
f9b0d84
to
9dbd569
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@muyihao nice change! i'd suggest the following
- change
pyproject.toml
by adding sections like[tool.mypy]
and[tool.ruff]
and configure whatever needed for python format. We need to let IDE to also respect the settings, the pyproject.toml should be the source of truth for everything about the python project including style - split into 2 PRs: first PR titled "style: ..." to include pyproject.toml and python style changes. it should also make the python lintting part of the GH actions workflow
compliance
- Move everything about pre commit to another PR titled
chore: ...
rev: v1.11.0 | ||
hooks: | ||
- id: mypy | ||
args: [ "--ignore-missing-imports" ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can all the python tools settings be put in pyproject.toml
? we can use section like [tool.mypy]
, [tool.ruff]
? we can use ruff instead of flake8+black, much faster
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #100 +/- ##
=======================================
Coverage 87.24% 87.24%
=======================================
Files 14 14
Lines 690 690
=======================================
Hits 602 602
Misses 88 88 ☔ View full report in Codecov by Sentry. |
@xushiyan Thanks for your suggestions! I appreciate your feedback. I've made the changes as per your recommendations. I've split the changes into two PRs: However, I noticed that the Compliance check failed upon submission. It doesn't seem related to my changes. The error message indicates an issue with a Rust dependency: arrow_schema::Schema::all_fields: Use flattened_fields instead. Should I address this issue within my PR, or would it be better to handle it separately? |
@muyihao looks like this is reported by clippy - yes feel free to raise another PR to fix the clippy warning, then we can land the python style change PR without touching rust code |
@muyihao interestingly clippy is checking against arrow 52.2.0 despite that cargo workspace is setting it to 52.0.0. do you know if we can make clippy to respect the exact dep version for checking? we may not want to upgrade arrow just because clippy complains - the rust code fix can be done when we manually decide to upgrade arrow. |
To ensure the project runs consistently across different environments, we should include the Cargo.lock file. |
hmmm that'd actually be an overkill, as lock file is generally not recommended for lib repo. the root fix is on the dep version itself (7566337). I've updated your style change PR - will make some setting tweaks and then merge it. We can now close this one. |
Description
This PR introduces pre-commit hooks to ensure code adheres to style guidelines and quality standards. The following hooks have been added:
General Hooks:
Python:
Rust:
Related Issue:
#5
#73
How are the changes test-covered