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

Merge dev to main #32

Merged
merged 40 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
64f46c5
update env
RobFirth Feb 1, 2023
71d1a36
first try at API wrangling - issue with pylint
RobFirth Feb 2, 2023
dfee47f
Merge remote-tracking branch 'origin' into 14-pylint-error-checking-t…
RobFirth Feb 6, 2023
2f8cebb
using JSONReporter
RobFirth Feb 6, 2023
52d39f1
update mypy and package version
RobFirth Mar 10, 2023
d97f586
use up-to-date poetry version
RobFirth Mar 10, 2023
758a6bf
variable expansion syntax doesn't need curly brackets
RobFirth Mar 10, 2023
b4de2b8
Update lint.yml
RobFirth Mar 10, 2023
4a10c03
use v3 of checkout
RobFirth Mar 10, 2023
85b234c
be explicit about the python version - 3.10.6
RobFirth Mar 10, 2023
bdbd0d3
runner is ubuntu 22 which doesn't have good support for python 3.10
RobFirth Mar 10, 2023
11731e9
downgrade ubuntu
RobFirth Mar 10, 2023
a73d799
use explicit variable, rather than envvar
RobFirth Mar 10, 2023
90fe615
use variable expansion with job scope
RobFirth Mar 10, 2023
ca4818b
expand vars in other stages
RobFirth Mar 10, 2023
cf34a57
use up-to-date version of cache
RobFirth Mar 10, 2023
9978dcd
be consistent with cache version
RobFirth Mar 10, 2023
19c940e
Merge pull request #24 from stfc/23-update-mypy
RobFirth Feb 15, 2024
5356f24
update regex version, switch to ruff
RobFirth Feb 15, 2024
9e9c77a
update workflow
RobFirth Feb 15, 2024
61649a3
Merge pull request #28 from stfc/27-update-to-regex-2022118-to-enable…
RobFirth Feb 15, 2024
91e4671
bump version to 0.3.6
RobFirth Feb 15, 2024
83c49bc
Merge pull request #30 from stfc/29-version-bump-following-27
RobFirth Feb 15, 2024
dea6dca
Merge branch 'dev' into 14-pylint-error-checking-throws-exeption-due-…
RobFirth Feb 15, 2024
6ced5a4
ruff reformat
RobFirth Feb 15, 2024
02fc85e
add exceptions for mypy pylint
RobFirth Feb 15, 2024
925e39f
use correct version
RobFirth Feb 15, 2024
d4593de
Merge pull request #15 from stfc/14-pylint-error-checking-throws-exep…
RobFirth Feb 15, 2024
8f8fc77
update to v0.3.7
RobFirth Feb 15, 2024
bafce78
Merge pull request #35 from stfc/34-version-bump-following-epylint-fix
RobFirth Feb 15, 2024
4c91051
Change { to {{
alexgregory1 Mar 8, 2024
5ab2a7d
Change branch name from master to main
Alex-JG3 Mar 8, 2024
70bbecb
Update version in index.rst
Alex-JG3 Mar 8, 2024
8664390
Add pylint as a dependency
Alex-JG3 Mar 8, 2024
af8eb4c
Upgrade poetry version
Alex-JG3 Mar 8, 2024
5bc2ada
Change src for ruff.
Alex-JG3 Mar 8, 2024
0881409
Make dev dependencies optional (not installed by default)
Alex-JG3 Mar 15, 2024
f9a213b
Install the optional dev dependencies in CI/CD pipeline
Alex-JG3 Mar 15, 2024
3dfbea8
Fix type by changing --with-dev to --with dev
Alex-JG3 Mar 15, 2024
1c1657e
Upgrade black
Alex-JG3 Mar 15, 2024
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
26 changes: 17 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,41 @@ name: lint

on: push

env:
POETRY_VERSION: "1.8.2"
PYTHON_VERSION: "3.9"
Alex-JG3 marked this conversation as resolved.
Show resolved Hide resolved

jobs:
lint:
name: Run linting tools
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v2.3.4
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Print PYTHON_VERSION
run: echo "Using python==$PYTHON_VERSION"

- name: Setup Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: ${{env.PYTHON_VERSION}}


- name: Permacache Poetry
id: cache-poetry
uses: actions/cache@v2.1.6
uses: actions/cache@v3
with:
path: ~/.poetry
key: poetry

- name: Install latest version of Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python3 -
POETRY_VERSION=$POETRY_VERSION curl -sSL https://install.python-poetry.org | python3 -
poetry version

- name: Add Poetry to $PATH
run: |
Expand All @@ -41,7 +50,7 @@ jobs:

- name: Cache dependencies
id: cache-deps
uses: actions/cache@v2.1.6
uses: actions/cache@v3
with:
path: ${{github.workspace}}/.venv
key: poetry-${{ hashFiles('**/poetry.lock') }}
Expand All @@ -51,12 +60,11 @@ jobs:
if: steps.cache-deps.cache-hit != 'true'
run: |
poetry config virtualenvs.in-project true
poetry install --no-interaction
poetry install --no-interaction --with dev

- name: Lint code
run: |
poetry run pylint --errors-only hooks
poetry run flake8 hooks
poetry run isort --check hooks
poetry run black --check --diff .
poetry run ruff check hooks
poetry run mypy hooks
17 changes: 11 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,37 @@ on:
tags:
- "v*"

env:
POETRY_VERSION: "1.8.2"
PYTHON_VERSION: "3.9"
RobFirth marked this conversation as resolved.
Show resolved Hide resolved

jobs:
autorelease:
name: Create Release
runs-on: "ubuntu-latest"
steps:
- name: Checkout code
uses: actions/checkout@v2.3.4
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Setup Python
uses: actions/setup-python@v2.2.2
uses: actions/setup-python@v4
with:
python-version: "3.9"
python-version: ${{ env.PYTHON_VERSION }}

- name: Permacache Poetry
id: cache-poetry
uses: actions/cache@v2.1.6
uses: actions/cache@v3
with:
path: ~/.poetry
key: poetry

- name: Install latest version of Poetry
if: steps.cache-poetry.outputs.cache-hit != 'true'
run: |
curl -sSL https://install.python-poetry.org | python3 -
POETRY_VERSION=$POETRY_VERSION curl -sSL https://install.python-poetry.org | python3 -
poetry --version

- name: Add Poetry to $PATH
run: |
Expand Down
21 changes: 13 additions & 8 deletions .github/workflows/sphinx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,30 @@ on:
tags: "*"
pull_request:
branches:
- master
- main

env:
POETRY_VERSION: "1.8.2"
PYTHON_VERSION: "3.9"

jobs:
build-docs:
runs-on: ubuntu-latest
runs-on: "ubuntu-latest"
steps:
- name: Checkout
uses: actions/checkout@master
uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: 3.9

- uses: abatilo/actions-poetry@v2.1.3
python-version: ${{ env.PYTHON_VERSION }}

- uses: abatilo/actions-poetry@v2
with:
poetry-version: ${{ env.POETRY_VERSION }}
- name: install
run: poetry install --extras docs
run: poetry install --with dev

- name: Build documentation
run: |
Expand Down
19 changes: 10 additions & 9 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/stfc/pre-commit-hooks
rev: v0.3.4
rev: v0.3.7
hooks:
- id: check-mypy-import-errors
- id: check-pylint-import-errors
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.2.0
rev: v4.5.0
hooks:
- id: check-toml
- id: check-yaml
Expand All @@ -30,11 +30,12 @@ repos:
hooks:
- id: black
language_version: python3
- repo: https://github.com/pycqa/isort
rev: 5.10.1
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.8
hooks:
- id: isort
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
# Run the linter.
- id: ruff
args: [ --fix ]
# Run the formatter.
- id: ruff-format
2 changes: 1 addition & 1 deletion doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ example configuration:

repos:
- repo: https://github.com/stfc/pre-commit-hooks
rev: v0.3.4
rev: v0.3.7
hooks:
- id: check-mypy-import-errors
- id: check-pylint-import-errors
Expand Down
31 changes: 17 additions & 14 deletions hooks/check_pylint_import_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import json
import sys
from io import StringIO
from typing import Optional

from pylint import epylint as lint
from pylint.lint import Run
from pylint.reporters import JSONReporter

from .utils import Hook, PyprojectFile, SetupFile
from .utils.config_file import ConfigFile
Expand Down Expand Up @@ -48,27 +50,28 @@ def run(self) -> int:
return 0

# set some pylint options to match the CI pipeline and use the output here:
pylint_opts = " ".join(
[
setup_file.package_name, # lint package files
f"--rcfile='{setup_file.path}'", # use local config file
" --output-format=json", # return json dict for subsequent parsing
]
)
pylint_output = StringIO() # Custom open stream
reporter = JSONReporter(pylint_output) # report to StringIO
pylint_opts = [
setup_file.package_name, # lint package files
f"--rcfile={setup_file.path}", # use local config file
]
# run pylint:
pylint_stdout, pylint_err = lint.py_run(pylint_opts, return_std=True)
# pylint_stdout, pylint_err = lint.py_run(pylint_opts, return_std=True)
Run(args=pylint_opts, reporter=reporter, exit=False) # New API

# raise any pylint running errors (i.e. not linting issues)
if len(pylint_err.getvalue()) > 0:
raise Exception(pylint_err.getvalue())
# # raise any pylint running errors (i.e. not linting issues)
# if len(pylint_err.getvalue()) > 0:
# raise Exception(pylint_err.getvalue())
# NOTE: Run API should raise these (famous last words...)

# grab lint issues as json dict:
pylint_output = json.loads(pylint_stdout.getvalue())
pylint_output_structure = json.loads(pylint_output.getvalue())

# get any package/module names from pylint import-error messages:
bad_imports = {
msg["message"].split("'")[1]
for msg in pylint_output
for msg in pylint_output_structure
if msg["message-id"] == "E0401"
}
if len(bad_imports) == 0:
Expand Down
1 change: 0 additions & 1 deletion hooks/utils/setup_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ def _generate_mypy_ignores(bad_modules: Union[str, Set[str]]) -> str:
self.contents = new_config

def add_pylint_ignore(self, bad_imports):

self._modify_section_line(
section_name="[pylint]",
line_start="ignored-modules = ",
Expand Down
Loading
Loading