Skip to content

Commit

Permalink
Replace flake8 and pals with hooked ruff and mypy
Browse files Browse the repository at this point in the history
🪝🐶
  • Loading branch information
ruksi committed Mar 6, 2023
1 parent dbd26ea commit 9332900
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 59 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
name: CI
'on':

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:

Test:
runs-on: '${{ matrix.os }}'
strategy:
Expand All @@ -22,31 +25,32 @@ jobs:
with:
python-version: '${{ matrix.python-version }}'
- uses: actions/checkout@v2
- run: 'pip install -e . -r requirements-test.txt'
- run: pip install -e . -r requirements-test.txt
- run: py.test -vvv --cov .
- uses: codecov/codecov-action@v3
env:
BOTO_CONFIG: /dev/null
AWS_SECRET_ACCESS_KEY: foobar_secret
AWS_ACCESS_KEY_ID: foobar_key

Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- uses: actions/checkout@v2
- run: 'pip install -e . -r requirements-lint.txt'
- run: flake8 hai
- run: mypy hai
- run: pip install -e . pre-commit
- run: pre-commit run --all-files

Build:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: '3.11'
- uses: actions/checkout@v2
- run: 'pip install build'
- run: pip install build
- run: python -m build .
- uses: actions/upload-artifact@v2
with:
Expand Down
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: debug-statements
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.254
hooks:
- id: ruff
args:
- --fix
- --exit-non-zero-on-fix

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.0.1
hooks:
- id: mypy
exclude: hai_tests/test_.*
args:
- --install-types
- --non-interactive
- --scripts-are-modules
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@ python

# Development

Installing editable library version in the current virtual environment.
Installing editable library version in the current virtual environment for development.

```bash
# development dependencies require Python 3.8+
pip install -e . -r requirements-lint.txt -r requirements-test.txt
pip install -e . -r requirements-test.txt pip-tools pre-commit && pre-commit install

# if you want to manually run lints...
pre-commit run --all-files

# if you want to run tests...
pytest

# if you want to try it out...
python
>>> import hai; print(hai.__version__)
```

# Releases

The library is released to both GitHub Releases (https://github.com/valohai/hai)
The library is released to both GitHub Releases (https://github.com/valohai/hai)
and PyPI (https://pypi.org/project/hai/) simultaneously.
5 changes: 3 additions & 2 deletions hai_tests/test_multipart_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def read_chunk(self, fp, size):

@mock_s3
@pytest.mark.parametrize('file_type', ('real', 'imaginary'))
@pytest.mark.parametrize('mpu_class', (MultipartUploader, ChunkCallbackMultipartUploader), ids=('no-func', 'chunk-func'))
@pytest.mark.parametrize(
'mpu_class', (MultipartUploader, ChunkCallbackMultipartUploader), ids=('no-func', 'chunk-func')
)
def test_multipart_upload(tmpdir, file_type, mpu_class):
if file_type == 'real':
temp_path = tmpdir.join('temp.dat')
Expand Down Expand Up @@ -47,7 +49,6 @@ def event_handler(**args):

mpu.on('*', event_handler)


if mpu_class is ChunkCallbackMultipartUploader:
mpu.chunk_sizes = []

Expand Down
17 changes: 17 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,20 @@ ignore_missing_imports = true
[[tool.mypy.overrides]]
module = "moto.*"
ignore_missing_imports = true

[tool.ruff]
target-version = "py37"
line-length = 120
mccabe.max-complexity = 10
select = [
"B", # bugbear
"C90", # mccabe
"E", # pycodestyle
"F", # pyflakes
"I", # isort
"T", # debugger and print
"W", # pycodestyle
]
ignore = [
"E741", # Ambiguous variable name
]
4 changes: 0 additions & 4 deletions requirements-lint.in

This file was deleted.

33 changes: 0 additions & 33 deletions requirements-lint.txt

This file was deleted.

11 changes: 0 additions & 11 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,5 @@ include_package_data = true
where = .
exclude = hai_tests

[flake8]
ignore = E741
max-line-length = 119
max-complexity = 10

[tool:pytest]
norecursedirs = .git .tox

[isort]
profile = black
line_length = 120
multi_line_output = 3
wrap_length = 120

0 comments on commit 9332900

Please sign in to comment.