Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches:
- main
pull_request:

jobs:

PyTest:
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.8"
- "3.9"
- "3.10"

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install --upgrade pip setuptools codecov
- run: python -m pip install -e .[test]
- run: relint **
- run: py.test --cov=.
- uses: codecov/codecov-action@v3
23 changes: 12 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
name: PyPi Release
name: Release

on: [release]
on:
release:
types: [published]

jobs:
build:

PyPi:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-python@v1
- name: Install dependencies
run: python -m pip install --upgrade pip setuptools wheel twine
- name: Build dist packages
run: python setup.py sdist bdist_wheel
- name: Upload packages
run: python -m twine upload dist/*
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- run: python -m pip install --upgrade pip build wheel twine
- run: python -m build --sdist --wheel
- run: python -m twine upload dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
26 changes: 0 additions & 26 deletions .github/workflows/tests.yml

This file was deleted.

2 changes: 1 addition & 1 deletion relint-pre-commit.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh

set -eo pipefail
git diff --staged | relint --diff "${@:1}"
git diff --staged | relint --diff -W "${@:1}"
12 changes: 9 additions & 3 deletions relint.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ def parse_args(args):
action='store_true',
help='Analyze content from git diff.'
)
parser.add_argument(
'-W',
'--fail-warnings',
action='store_true',
help='Fail for warnings.'
)
return parser.parse_args(args=args)


def load_config(path):
def load_config(path, fail_warnings):
with open(path) as fs:
for test in yaml.safe_load(fs):
filename = test.get('filename')
Expand All @@ -76,7 +82,7 @@ def load_config(path):
hint=test.get('hint'),
file_pattern=file_pattern,
filename=filename,
error=test.get('error', True)
error=test.get('error', True) or fail_warnings
)


Expand Down Expand Up @@ -217,7 +223,7 @@ def main(args=sys.argv[1:]):
for path in glob.iglob(glob.escape(file), recursive=True)
}

tests = list(load_config(args.config))
tests = list(load_config(args.config, args.fail_warnings))

matches = chain.from_iterable(
lint_file(path, tests)
Expand Down
13 changes: 7 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[metadata]
name = relint
author = Johannes Hoppe
author_email = info@johanneshoppe.com
author = Johannes Maron
author_email = johannes@maron.family
description = Write your own linting rules using regular expressions
long_description = file: README.rst
url = https://github.com/codingjoe/relint
license = MIT
license_file = LICENSE
classifier =
Development Status :: 4 - Beta
Development Status :: 5 - Production/Stable
Environment :: Console
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Expand All @@ -25,12 +25,13 @@ keywords =
install_requires = PyYAML
setup_requires =
setuptools_scm
pytest-runner
tests_require =
py_modules = relint

[options.extras_require]
test =
pytest
pytest-cov
pytest-mock
py_modules = relint

[options.entry_points]
console_scripts =
Expand Down
7 changes: 7 additions & 0 deletions test_relint.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def test_main_execution(self, mocker, filename):

assert exc_info.value.code == 0

@pytest.mark.parametrize('filename', ['test_relint.py', '[a-b].py', '[b-a].py'])
def test_main_execution(self, mocker, filename):
with pytest.raises(SystemExit) as exc_info:
main(['relint.py', '-W', filename])

assert exc_info.value.code != 0

def test_main_execution_with_diff(self, capsys, mocker, tmpdir):
tmpdir.join('.relint.yml').write(open('.relint.yml').read())
tmpdir.join('dummy.py').write("# TODO do something")
Expand Down