Skip to content

Commit

Permalink
Merge pull request #25 from valohai/barky-upgrades-and-hooks
Browse files Browse the repository at this point in the history
Setup `ruff`, hooks and development upgrades
  • Loading branch information
akx authored Mar 6, 2023
2 parents 2f7433f + e1195e4 commit 99c0ad0
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 82 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
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +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
pip install -e .[dev] # optionally replace . with the path to hai root
# development dependencies require Python 3.8+
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
4 changes: 0 additions & 4 deletions mypy.ini

This file was deleted.

33 changes: 33 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,36 @@ requires = [
"wheel"
]
build-backend = "setuptools.build_meta"

[tool.mypy]
strict = true
exclude = "hai_tests/test_.*"

[[tool.mypy.overrides]]
module = "boto3.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "botocore.*"
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.

35 changes: 16 additions & 19 deletions requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
#
# pip-compile requirements-test.in
#
attrs==22.1.0
attrs==22.2.0
# via pytest
boto3==1.26.25
boto3==1.26.84
# via moto
botocore==1.29.25
botocore==1.29.84
# via
# boto3
# moto
Expand All @@ -17,48 +17,45 @@ certifi==2022.12.7
# via requests
cffi==1.15.1
# via cryptography
charset-normalizer==2.1.1
charset-normalizer==3.1.0
# via requests
coverage[toml]==6.5.0
coverage[toml]==7.2.1
# via pytest-cov
cryptography==38.0.4
cryptography==39.0.2
# via moto
exceptiongroup==1.0.4
exceptiongroup==1.1.0
# via pytest
idna==3.4
# via requests
iniconfig==1.1.1
iniconfig==2.0.0
# via pytest
jinja2==3.1.2
# via moto
jmespath==1.0.1
# via
# boto3
# botocore
markupsafe==2.1.1
markupsafe==2.1.2
# via
# jinja2
# moto
# werkzeug
moto==4.0.11
moto==4.1.4
# via -r requirements-test.in
packaging==22.0
packaging==23.0
# via pytest
pluggy==1.0.0
# via pytest
pycparser==2.21
# via cffi
pytest==7.2.0
pytest==7.2.2
# via pytest-cov
pytest-cov==4.0.0
# via -r requirements-test.in
python-dateutil==2.8.2
# via
# botocore
# moto
pytz==2022.6
# via moto
requests==2.28.1
requests==2.28.2
# via
# moto
# responses
Expand All @@ -74,14 +71,14 @@ tomli==2.0.1
# via
# coverage
# pytest
types-toml==0.10.8.1
types-toml==0.10.8.5
# via responses
urllib3==1.26.13
urllib3==1.26.14
# via
# botocore
# requests
# responses
werkzeug==2.2.2
werkzeug==2.2.3
# via moto
xmltodict==0.13.0
# via moto
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 99c0ad0

Please sign in to comment.