-
Notifications
You must be signed in to change notification settings - Fork 5
Added Support for Python 3.13 #358
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9c28823
Added support for Python 3.13 and included tox
f-allian f68d27b
Included pre-commit workflow
f-allian b466100
Update README.md
f-allian 268f35f
Update CONTRIBUTING.md
f-allian 638c92c
Fixes to PR suggestions
f-allian 204e58a
Merge remote-tracking branch 'origin/f-allian/forward-compatibility' …
f-allian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| repos: | ||
| - repo: https://github.com/pre-commit/pre-commit-hooks | ||
| rev: v6.0.0 | ||
| hooks: | ||
| - id: trailing-whitespace | ||
| - id: end-of-file-fixer | ||
| - id: check-yaml | ||
| - id: check-toml | ||
| - id: check-added-large-files | ||
| - id: check-merge-conflict | ||
| - id: debug-statements | ||
| - id: mixed-line-ending | ||
| files: \.py$ | ||
|
|
||
| # Black | ||
| - repo: https://github.com/psf/black | ||
| rev: 25.9.0 | ||
| hooks: | ||
| - id: black | ||
| args: ['--line-length=120', '--target-version=py310'] | ||
| files: ^causal_testing/ | ||
|
|
||
| # isort | ||
| - repo: https://github.com/pycqa/isort | ||
| rev: 7.0.0 | ||
| hooks: | ||
| - id: isort | ||
| args: ['--profile', 'black', '--line-length', '120'] | ||
| files: ^causal_testing/ | ||
|
|
||
| # Pylint | ||
| - repo: local | ||
| hooks: | ||
| - id: pylint | ||
| name: pylint | ||
| entry: pylint | ||
| language: system | ||
| types: [python] | ||
| args: ['--max-line-length=120', '--max-positional-arguments=12'] | ||
| files: ^causal_testing/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # How to Contribute | ||
|
|
||
| ### Questions | ||
| Please ask any questions about the Causal Testing Framework or surrounding concepts on the | ||
| [discussions board](https://github.com/CITCOM-project/CausalTestingFramework/discussions). Before opening a new | ||
| discussion, please see whether a relevant one already exists - someone may have answered your question already. | ||
|
|
||
| ### Reporting Bugs and Making Suggestions | ||
| Upon identifying any bugs or features that could be improved, please open an | ||
| [issue](https://github.com/CITCOM-project/CausalTestingFramework/issues) and label with bug or feature suggestion. Every issue | ||
| should clearly explain the bug or feature to be improved and, where necessary, instructions to replicate. We also | ||
| provide templates for common scenarios when creating an issue. | ||
|
|
||
| ### Contributing to the Codebase | ||
| To contribute to our work, please ensure the following: | ||
|
|
||
| 1. [Fork the repository](https://help.github.com/articles/fork-a-repo/) into your own GitHub account, and [clone](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository) it to your local machine. | ||
| 2. [Create a new branch](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-and-deleting-branches-within-your-repository) in your forked repository. Give this branch an appropriate name, and create commits that describe the changes. | ||
| 3. [Push your changes](https://docs.github.com/en/get-started/using-git/pushing-commits-to-a-remote-repository) to your new branch in your remote fork, compare with `CausalTestingFramework/main`, and ensure any conflicts are resolved. | ||
| 4. Create a draft [pull request](https://docs.github.com/en/get-started/quickstart/hello-world#opening-a-pull-request) from your branch, and ensure you have [linked](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/autolinked-references-and-urls) it to any relevant issues in your description. | ||
|
|
||
| ### Continuous Integration (CI) and Code Quality | ||
| Our CI/CD tests include: | ||
| - Build: Install the necessary Python and runtime dependencies. | ||
| - Linting: [pylint](https://pypi.org/project/pylint/) is employed for our code linter and analyser. | ||
| - Testing: We use the [unittest]() module to develop our tests and the [pytest](https://pytest.org/en/latest/) framework as our test discovery. | ||
| - Formatting: We use [black](https://pypi.org/project/black/) for our code formatting. | ||
|
|
||
| To find the other (optional) developer dependencies, please check `pyproject.toml`. | ||
|
|
||
| ### Pre-commit Hooks | ||
| We use [pre-commit](https://pre-commit.com/) to automatically run code quality checks before each commit. This ensures consistent code style and catches issues early. | ||
|
|
||
| Automated checks include: | ||
|
|
||
| - Trailing whitespace removal. | ||
| - End-of-file fixing. | ||
| - YAML and TOML validation. | ||
| - Black formatting. | ||
| - isort import sorting. | ||
| - Pylint code analysis. | ||
|
|
||
| To use pre-commit: | ||
| ```bash | ||
| # Install pre-commit hooks (one-time setup of .pre-commit-config.yaml) | ||
| pre-commit install | ||
|
|
||
| # Manually run hooks on all files (optional) | ||
| pre-commit run --all-files | ||
| ``` | ||
|
|
||
| ### Coding Style | ||
| In the Causal Testing Framework, we aim to provide highly reusable and easily maintainable packages. To this end, | ||
| we ask contributors to stick to the following guidelines: | ||
| 1. Make small and frequent changes rather than verbose and infrequent changes. | ||
| 2. Favour readable and informative variable, method, and class names over concise names. | ||
| 3. Use logging instead of print. | ||
| 4. For every method and class, include detailed docstrings following the | ||
| [reStructuredText/Sphinx](https://sphinx-rtd-tutorial.readthedocs.io/en/latest/docstrings.html) guidelines. | ||
| 5. Add credit and license information where existing code has been used (in the method or class docstring). | ||
| 6. If a method implements a specific algorithm/technique from a paper, add a citation to the docstring. | ||
| 7. Use [variable](https://www.python.org/dev/peps/pep-0008/#variable-annotations) and [function](https://www.python.org/dev/peps/pep-0008/#function-annotations) | ||
| annotations. | ||
| 8. All methods should be thoroughly tested with PyTest (see [Testing]() below). | ||
| 9. Code formatting and linting is handled automatically by pre-commit hooks (see above). | ||
|
|
||
| ### Manual Code Quality Checks (Optional) | ||
| While pre-commit handles most formatting automatically, you can run these commands manually if needed: | ||
|
|
||
| ```bash | ||
| # Format code | ||
| black causal_testing | ||
|
|
||
| # Sort imports | ||
| isort causal_testing | ||
|
|
||
| # Run linter | ||
| pylint causal_testing | ||
|
|
||
| # Run tests | ||
| pytest | ||
| ``` | ||
|
|
||
| ### Compatibility Testing Across Python Versions with tox | ||
|
|
||
| For compatibility testing Python versions, we use [tox](https://pypi.org/project/tox/) to automate | ||
| testing across all supported Python versions (3.10, 3.11, 3.12, and 3.13): | ||
|
|
||
| - Install tox: `pip install tox`. | ||
| - Test all versions: `tox` (runs tests on all Python versions + linting in the root folder). | ||
| - Test specific version: `tox -e py313` (or py310, py311, py312). | ||
| - Quick iteration: Use `pytest` directly for fast testing during development. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will this block commits that aren't perfectly linted? I'm not sure I want this. Sometimes it takes a while to resolve and I need to commit something I know isn't right. I know you can disable checks, but I prefer not to have commits be blocked. Obviously if it can fix it itself, then that's fine, but if it's everything, then that could get annoying.
Uh oh!
There was an error while loading. Please reload this page.
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.
@jmafoster1 - no, pre-commit doesn't completely block anything from being committed, it fixes it instead. The workflow is like this: 1) your script(s) contain unlinted, unformatted code 2) you commit files naively or run manually run
pre-commitbefore committing 3) pre-commit identifies and initially "blocks" commits due to the rules defined in the pre-commit config 4) pre-commit formats and lints it for you 5) you commit as normal.To avoid it "blocking" your commit from the get-go, just run
pre-commit run --all-filesbefore committing.