Skip to content

Commit

Permalink
MRG: #224 from vocalpy/add-fix-linting
Browse files Browse the repository at this point in the history
Add / fix linting
  • Loading branch information
NickleDave committed Feb 28, 2023
2 parents 075f3e3 + b122b2a commit 97c11e9
Show file tree
Hide file tree
Showing 67 changed files with 1,552 additions and 1,999 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
with:
options: "--line-length=120"
src: "./src"
- uses: actions/setup-python@v2
with:
python-version: 3.8
- name: install libsndfile1 on ubuntu
if: matrix.os == 'ubuntu-latest'
run: sudo apt install libsndfile1
- name: install
run: |
pip install nox
pip install '.[dev]'
- name: isort lint
uses: isort/isort-action@master
with:
configuration: "./src"
- name: flake8 lint
uses: py-actions/flake8@v2
with:
max-line-length: "120"
path: "./src"
exclude: "./src/crowsetta/_vendor"
49 changes: 49 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.4.0"
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
- id: debug-statements
- id: end-of-file-fixer
- id: mixed-line-ending
- id: name-tests-test
args: ["--pytest-test-first"]
- id: requirements-txt-fixer
- id: trailing-whitespace

# Autoremoves unused imports
- repo: https://github.com/hadialqattan/pycln
rev: v1.1.0
hooks:
- id: pycln
args: [--config=pyproject.toml]
files: ^src/|^tests/

- repo: https://github.com/pycqa/isort
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
files: ^src/|^tests/

- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
- id: black
args:
- --line-length=120
files: ^src/|^tests/

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
args:
- "--max-line-length=120"
files: ^src/|^tests/
additional_dependencies: &flake8-dependencies
- flake8-bugbear
13 changes: 11 additions & 2 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,22 @@ def dev(session: nox.Session) -> None:
session.run(python, "-m", "pip", "install", "-e", ".[dev,test,doc]", external=True)


@nox.session
def lint(session):
"""
Run the linter.
"""
session.install("pre-commit")
session.run("pre-commit", "run", "--all-files", *session.posargs)


@nox.session
def test(session) -> None:
"""
Run the unit and regular tests.
"""
session.install(".[test]")
session.run("pytest", *session.posargs)
session.run("pytest", "-n", "auto", *session.posargs)


@nox.session
Expand All @@ -66,7 +75,7 @@ def coverage(session) -> None:
"""
session.install(".[test]", "pytest-cov")
session.run(
"pytest", "--cov=./", "--cov-report=xml", *session.posargs
"pytest", "-n", "auto", "--cov=./", "--cov-report=xml", *session.posargs
)


Expand Down
8 changes: 7 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ classifiers = [
[project.optional-dependencies]
test = [
"pytest >=6.2.1",
"pytest-cov >=2.12.0"
"pytest-cov >=2.12.0",
"pytest-xdist >=3.2.0",
]
doc = [
"ipython != 8.7.0",
Expand All @@ -58,7 +59,12 @@ doc = [
"sphinx-tabs >= 3.3.1",
]
dev = [
'black >=23.1.0',
'crowsetta[doc, test]',
'flake8 >=6.0.0',
'flit',
'isort >=5.12.0',
'pycln >=2.1.3',
'twine',
]

Expand Down
43 changes: 30 additions & 13 deletions src/crowsetta/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import data, interface, typing, validation
from .__about__ import (
__author__,
__commit__,
Expand All @@ -9,22 +10,38 @@
__uri__,
__version__,
)

# --- need to import everything used by formats before importing formats
# to avoid circular import errors
from . import (
data,
interface,
typing,
validation
)

from .annotation import Annotation
from .bbox import BBox
from .transcriber import Transcriber
from .segment import Segment
from .sequence import Sequence
from .annotation import Annotation
from .transcriber import Transcriber

# ok, now it's safe to import formats
# Need to import formats last to avoid circular import errors
# isort: off
from . import formats
from .formats import register_format

# isort: on

__all__ = [
"__author__",
"__commit__",
"__copyright__",
"__email__",
"__license__",
"__summary__",
"__title__",
"__uri__",
"__version__",
"Annotation",
"BBox",
"data",
"formats",
"interface",
"register_format",
"Segment",
"Sequence",
"Transcriber",
"typing",
"validation",
]
2 changes: 1 addition & 1 deletion src/crowsetta/_vendor/textgrid/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .textgrid import TextGrid, MLF, IntervalTier, PointTier, Interval, Point
from .textgrid import MLF, Interval, IntervalTier, Point, PointTier, TextGrid
3 changes: 1 addition & 2 deletions src/crowsetta/_vendor/textgrid/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@

class TextGridError(Exception):
pass
pass

0 comments on commit 97c11e9

Please sign in to comment.