Skip to content

Commit

Permalink
Merge pull request #166 from WMD-group/ruff
Browse files Browse the repository at this point in the history
Overhaul pre-commit
  • Loading branch information
AntObi authored Aug 19, 2024
2 parents ab02a1f + ae3fa47 commit caa28af
Show file tree
Hide file tree
Showing 84 changed files with 905,521 additions and 7,551 deletions.
4 changes: 2 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[flake8]
max-line-length = 88
extend-ignore =
extend-ignore =
# E203: whitespace before ':' (black compatibility)
E203,
#D105: Missing docstring in magic method
D105
D105
7 changes: 3 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,15 @@ Please describe the tests that you ran to verify your changes. Provide instructi
- [ ] Test B

**Test Configuration**:
* Python version:
* Operating System:

- Python version:
- Operating System:

## Reviewers

@mention individuals who you specifically want to involve in the discussion for this pull request and mention why they are needed in the discussion/why they are needed to review the pull request.


## Checklist:
## Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
Expand Down
57 changes: 28 additions & 29 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@
changelog:
exclude:
authors: [dependabot, github-actions, pre-commit-ci]
categories:
- title: 🎉 New Features
labels: [feature]
- title: 🐛 Bug Fixes
labels: [fix]
- title: 🛠 Enhancements
labels: [enhancement, DX, UX]
- title: 📖 Documentation
labels: [docs]
- title: 🧹 House-Keeping
labels: [housekeeping]
- title: 🚀 Performance
labels: [performance]
- title: 💡 Refactoring
labels: [refactor]
- title: 🧪 Tests
labels: [tests]
- title: 💥 Breaking Changes
labels: [breaking]
- title: 🔒 Security Fixes
labels: [security]
- title: 🏥 Package Health
labels: [pkg]
- title: 🤷‍♂️ Other Changes
labels: ["*"]

changelog:
exclude:
authors: [dependabot, github-actions, pre-commit-ci]
categories:
- title: 🎉 New Features
labels: [feature]
- title: 🐛 Bug Fixes
labels: [fix]
- title: 🛠 Enhancements
labels: [enhancement, DX, UX]
- title: 📖 Documentation
labels: [docs]
- title: 🧹 House-Keeping
labels: [housekeeping]
- title: 🚀 Performance
labels: [performance]
- title: 💡 Refactoring
labels: [refactor]
- title: 🧪 Tests
labels: [tests]
- title: 💥 Breaking Changes
labels: [breaking]
- title: 🔒 Security Fixes
labels: [security]
- title: 🏥 Package Health
labels: [pkg]
- title: 🤷‍♂️ Other Changes
labels: ["*"]
53 changes: 25 additions & 28 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
- main

jobs:

qa:
runs-on: ubuntu-latest
steps:
Expand All @@ -18,33 +17,31 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.9","3.10","3.11","3.12"]
os: [ubuntu-latest,macos-latest,windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12"]
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -e ".[dev]"
- name: Check package versions
run: |
pip show -V elementembeddings
pip show -V pytest
pip show -V matplotlib
- name: Run tests
run: python -m pytest --mpl --mpl-baseline-path=src/elementembeddings/tests/baseline --cov=src/elementembeddings --cov-report=xml -v
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip wheel
python -m pip install -e ".[dev]"
- name: Check package versions
run: |
pip show -V elementembeddings
pip show -V pytest
pip show -V matplotlib
- name: Run tests
run: python -m pytest --mpl --mpl-baseline-path=src/elementembeddings/tests/baseline --cov=src/elementembeddings --cov-report=xml -v
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
verbose: true
22 changes: 11 additions & 11 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
name: 'Combine PRs'
name: "Combine PRs"

# Controls when the action will run - in this case triggered manually
on:
workflow_dispatch:
inputs:
branchPrefix:
description: 'Branch prefix to find combinable PRs based on'
description: "Branch prefix to find combinable PRs based on"
required: true
default: 'dependabot'
default: "dependabot"
mustBeGreen:
description: 'Only combine PRs that are green (status is success)'
description: "Only combine PRs that are green (status is success)"
required: true
default: true
combineBranchName:
description: 'Name of the branch to combine PRs into'
description: "Name of the branch to combine PRs into"
required: true
default: 'combine-prs-branch'
default: "combine-prs-branch"
ignoreLabel:
description: 'Exclude PRs with this label'
description: "Exclude PRs with this label"
required: true
default: 'nocombine'
default: "nocombine"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
Expand Down Expand Up @@ -115,7 +115,7 @@ jobs:
core.setFailed('Failed to create combined branch - maybe a branch by that name already exists?');
return;
}
let combinedPRs = [];
let mergeFailedPRs = [];
for(const { branch, prString } of branchesAndPRStrings) {
Expand All @@ -133,7 +133,7 @@ jobs:
mergeFailedPRs.push(prString);
}
}
console.log('Creating combined PR');
const combinedPRsString = combinedPRs.join('\n');
let body = '✅ This PR was created by the Combine PRs action by combining the following PRs:\n' + combinedPRsString;
Expand All @@ -148,4 +148,4 @@ jobs:
head: '${{ github.event.inputs.combineBranchName }}',
base: baseBranch,
body: body
});
});
4 changes: 2 additions & 2 deletions .github/workflows/latest_docs.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build/Publish Develop Docs
name: Build/Publish Develop Docs
on:
push:
branches:
Expand All @@ -22,6 +22,6 @@ jobs:
git fetch origin gh-pages --depth=1
git config --global user.name "Docs Deploy"
git config --global user.email "[email protected]"
- name: Build Docs Website
run: mike deploy --push main latest
33 changes: 16 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,22 @@ permissions:

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@ec4db0b4ddc65acdf4bff5fa45ac92d78b56bdf0
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
87 changes: 48 additions & 39 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,55 @@
ci:
autoupdate_schedule: quarterly
autofix_commit_msg: pre-commit auto-fixes
autoupdate_commit_msg: pre-commit autoupdate
skip: [eslint, pyright]

repos:
- repo: https://github.com/timothycrosley/isort
rev: "5.12.0"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
hooks:
- id: isort
additional_dependencies: [toml]
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/psf/black
rev: "23.10.1"
- id: ruff
args: [--fix]
- id: ruff-format

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: black-jupyter
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.0
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.41.0
hooks:
- id: pyupgrade
args: [--py38-plus]
- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
- id: markdownlint
# MD013: line too long
# MD024: Multiple headings with the same content
# MD033: no inline HTML
# MD041: first line in a file should be a top-level heading
# MD025: single title
args: [--disable, MD013, MD024, MD025, MD033, MD041, "--"]
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: flake8
additional_dependencies: [flake8-docstrings]
#- repo: https://github.com/pre-commit/mirrors-autopep8
#rev: v2.0.0
#hooks:
# - id: autopep8
- repo: https://github.com/nbQA-dev/nbQA
rev: "1.7.0"
- id: nbstripout
args: [--drop-empty-cells, --keep-output]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
#- #id: nbqa-isort
#additional_dependencies: [isort==5.10.1]
#- id: nbqa-flake8
# additional_dependencies: [flake8==6.0.0]
# args: [--ignore=E501] # E501 line too long
- id: nbqa-pyupgrade
additional_dependencies: [pyupgrade==3.3.1]
- id: nbqa-autopep8
additional_dependencies: [autopep8==2.0.0]
args: ["--ignore=E501"]
- repo: https://github.com/roy-ht/pre-commit-jupyter
rev: v1.2.1
- id: prettier
args: [--write] # edit files in-place
additional_dependencies:
- prettier
- repo: https://github.com/RobertCraigie/pyright-python
rev: v1.1.376
hooks:
- id: jupyter-notebook-cleanup
args:
# - --remove-kernel-metadata
- --pin-patterns
- "[pin];[donotremove]"
- id: pyright
args: [--level, error]
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
stages: [commit, commit-msg]
args: [--toml, pyproject.toml]
additional_dependencies:
- tomli
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

<!-- insertion marker -->

## Unreleased

<small>[Compare with latest](https://github.com/WMD-group/ElementEmbeddings/compare/v0.3.0...HEAD)</small>
Expand All @@ -19,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Removed warning ([271f61e](https://github.com/WMD-group/ElementEmbeddings/commit/271f61e8653b706a6dd716bf6c0ced9396965750) by Anthony Onwuli).

<!-- insertion marker -->

## [v0.3.0](https://github.com/WMD-group/ElementEmbeddings/releases/tag/v0.3.0) - 2023-08-07

<small>[Compare with v0.2.0](https://github.com/WMD-group/ElementEmbeddings/compare/v0.2.0...v0.3.0)</small>
Expand Down Expand Up @@ -53,7 +55,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Fix package name in contributing.md ([075e657](https://github.com/WMD-group/ElementEmbeddings/commit/075e657d260aa72fca91c7f8cc57466235788426) by Anthony Onwuli).
- Fixed bug with is_standarised attribute ([ebaf773](https://github.com/WMD-group/ElementEmbeddings/commit/ebaf773134c8ab4988f071da9eca2193e4340f60) by Anthony Onwuli).
- Fixed composistion featuriser test ([3b729c9](https://github.com/WMD-group/ElementEmbeddings/commit/3b729c9584bf7cc4de2fd5c70baff41c8753800b) by Anthony Onwuli).
- Fixed composition featuriser test ([3b729c9](https://github.com/WMD-group/ElementEmbeddings/commit/3b729c9584bf7cc4de2fd5c70baff41c8753800b) by Anthony Onwuli).
- Fixed dim for linear/scalar representations ([f6cc681](https://github.com/WMD-group/ElementEmbeddings/commit/f6cc681ee4f343240f5bb4d49cf9dfc5fa89f455) by Anthony Onwuli).

### Changed
Expand Down Expand Up @@ -174,4 +176,3 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- removed numba from requirements.txt ([1eb833e](https://github.com/WMD-group/ElementEmbeddings/commit/1eb833ec1769ead345de23e2c09c92cee72cc545) by Anthony).
- removed the old AtomicEmbeddings.py file ([9b1b2e8](https://github.com/WMD-group/ElementEmbeddings/commit/9b1b2e82e0426136020f5112d12c18051d9b7c30) by Anthony).
- removed itertools from reqssetup.py ([c9c21ca](https://github.com/WMD-group/ElementEmbeddings/commit/c9c21ca8a8e242fc99f19d1fee204da7a1bbdc62) by Anthony).

Loading

0 comments on commit caa28af

Please sign in to comment.