Skip to content

Commit

Permalink
Merge pull request #47 from browniebroke/linting-workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
browniebroke authored May 18, 2020
2 parents bef6a4e + 758d3b8 commit 4bfedc5
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 21 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Lint

on:
push:
branches:
- master
pull_request:

jobs:
lint:
strategy:
matrix:
linter:
- name: Flake8
run: flake8 --config=setup.cfg
- name: Black
run: black --check .
- name: PyUpgrade
run: pyupgrade --py3-plus `find . -name "*.py"`
- name: iSort
run: isort -c -vb
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
version: 3.8
- name: Install Dependencies
run: |
python -m pip install -U pip
pip install -r requirements-dev.txt
- name: ${{ matrix.linter.name }}
run: ${{ matrix.linter.run }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v2.3.0
rev: v2.4.3
hooks:
- id: pyupgrade
args: [--py3-plus]
Expand Down
2 changes: 1 addition & 1 deletion django_codemod/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import List

import libcst as cst
from libcst.codemod import VisitorBasedCodemodCommand, ContextAwareTransformer
from libcst.codemod import ContextAwareTransformer, VisitorBasedCodemodCommand


class BaseCodemodCommand(VisitorBasedCodemodCommand, ABC):
Expand Down
4 changes: 2 additions & 2 deletions django_codemod/commands/django_codemod.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from .base import BaseCodemodCommand
from ..visitors.django_30 import (
RenderToResponseToRenderTransformer,
InlineHasAddPermissionsTransformer,
RenderToResponseToRenderTransformer,
)
from ..visitors.django_40 import (
ForceTextToForceStrTransformer,
Expand All @@ -13,6 +12,7 @@
UNGetTextToNGetTextTransformer,
URLToRePathTransformer,
)
from .base import BaseCodemodCommand


class Django30Command(BaseCodemodCommand):
Expand Down
15 changes: 7 additions & 8 deletions django_codemod/visitors/base.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
"""Module to implement base functionality."""

from abc import ABC
from typing import Union, Sequence
from typing import Sequence, Union

from libcst import (
matchers as m,
RemovalSentinel,
Call,
Arg,
BaseExpression,
Call,
MaybeSentinel,
Name,
RemovalSentinel,
RemoveFromParent,
Arg,
MaybeSentinel,
)
from libcst._nodes.statement import ImportFrom, BaseSmallStatement
from libcst import matchers as m
from libcst._nodes.statement import BaseSmallStatement, ImportFrom
from libcst.codemod import ContextAwareTransformer
from libcst.codemod.visitors import AddImportsVisitor

Expand Down
10 changes: 5 additions & 5 deletions django_codemod/visitors/django_30.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
from typing import Sequence, Union

from libcst import (
Call,
Name,
Arg,
RemovalSentinel,
matchers as m,
ClassDef,
BaseStatement,
Call,
ClassDef,
FunctionDef,
Name,
Param,
RemovalSentinel,
)
from libcst import matchers as m
from libcst.codemod import ContextAwareTransformer

from .base import BaseSimpleFuncRenameTransformer
Expand Down
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
import os
import sys

import django_codemod # noqa E402

sys.path.insert(0, os.path.abspath(".."))

import django_codemod # noqa E402

# -- General configuration ---------------------------------------------

Expand Down
2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ black==19.10b0
bump2version==1.0.0
coverage==5.1
flake8==3.8.1
flake8-isort==3.0.0
parameterized==0.7.4
pre-commit==2.4.0
pytest-runner==5.2
pytest==5.4.2
pyupgrade==2.4.3
tox==3.15.0
twine==3.1.1
watchdog==0.10.2
Expand Down
8 changes: 8 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,11 @@ test = pytest

[tool:pytest]
collect_ignore = ['setup.py']

[tool:isort]
multi_line_output = 3
include_trailing_comma = True
force_grid_wrap = 0
use_parentheses = True
line_length = 88
known_first_party = tests,django_codemod
3 changes: 2 additions & 1 deletion tests/visitors/test_django_30.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from parameterized import parameterized

from django_codemod.visitors.django_30 import (
RenderToResponseToRenderTransformer,
InlineHasAddPermissionsTransformer,
RenderToResponseToRenderTransformer,
)

from .base import BaseVisitorTest


Expand Down
5 changes: 3 additions & 2 deletions tests/visitors/test_django_40.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
from django_codemod.visitors.django_40 import (
ForceTextToForceStrTransformer,
SmartTextToForceStrTransformer,
UGetTextToGetTextTransformer,
UGetTextLazyToGetTextLazyTransformer,
UGetTextNoopToGetTextNoopTransformer,
UNGetTextToNGetTextTransformer,
UGetTextToGetTextTransformer,
UNGetTextLazyToNGetTextLazyTransformer,
UNGetTextToNGetTextTransformer,
URLToRePathTransformer,
)

from .base import BaseVisitorTest


Expand Down

0 comments on commit 4bfedc5

Please sign in to comment.