Skip to content

Commit

Permalink
Add taskfile and GH workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter554 committed Oct 17, 2023
1 parent fb68e6a commit d705a16
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,20 @@
name: CI
on:
push:
jobs:
check-code:
name: Check the code
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install taskfile
run: sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b /usr/local/bin
- name: Install poetry
run: curl -sSL https://install.python-poetry.org | python -
- name: Install Python dependencies
run: poetry install
- name: Check
run: task check
14 changes: 14 additions & 0 deletions Taskfile.yml
@@ -0,0 +1,14 @@
version: '3'

tasks:
test:
cmds:
- poetry run pytest {{.CLI_ARGS}}

lint:
cmds:
- poetry run black . --check

fmt:
cmds:
- poetry run black .
7 changes: 5 additions & 2 deletions codemodimportfrom/codemodimportfrom.py
Expand Up @@ -66,9 +66,11 @@ def visit_ImportFrom(self, node: cst.ImportFrom) -> bool | None:

def leave_ImportFrom(
self, original_node: cst.ImportFrom, updated_node: cst.ImportFrom
) -> cst.BaseSmallStatement | cst.FlattenSentinel[
) -> (
cst.BaseSmallStatement
] | cst.RemovalSentinel:
| cst.FlattenSentinel[cst.BaseSmallStatement]
| cst.RemovalSentinel
):
if original_node in self._import_aliases_by_import:
nodes = []
imports_to_add = self._imports_to_add_by_import[original_node]
Expand All @@ -86,6 +88,7 @@ def leave_ImportFrom(
],
)
)

if imports_to_add:
for import_to_add in sorted(imports_to_add):
nodes.append(
Expand Down

0 comments on commit d705a16

Please sign in to comment.