Skip to content

Commit

Permalink
add ci check for unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Goodman committed Feb 19, 2020
1 parent e839f45 commit f3d2007
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 39 deletions.
28 changes: 13 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,33 @@ jobs:
# Check formatting
# ----------------------------------

check_black_formatting:
check_static_analysis:
docker:
- image: python:3.6
steps:
- checkout

- run:
name: Install Black
command: pip install black
name: Install packages for static analysis
command: pip install black mypy mypy_extensions autoflake

- run:
name: Run Black
command: black --check .

check_mypy_typing:
docker:
- image: python:3.6
steps:
- checkout

- run:
name: Install mypy
command: pip install mypy mypy_extensions

- run:
name: Run mypy
command: mypy src/

- run:
name: Check for potentially unused imports
command: |
if [[ $(autoflake --remove-all-unused-imports -r --exclude __init__.py src | tee .unused-imports.txt | wc -c ) -ne 0 ]]; then
echo "Potentially unused imports found"
cat .unused-imports.txt
exit 2
fi
check_documentation:
docker:
- image: python:3.6
Expand Down Expand Up @@ -370,8 +369,7 @@ workflows:

"Check code style and docs":
jobs:
- check_black_formatting
- check_mypy_typing
- check_static_analysis
- check_documentation

"Build docker images":
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ __pycache__/
*.py[cod]
*$py.class

.unused-imports.txt

# C extensions
*.so

Expand Down
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- repo: local
hooks:
- id: black
name: black
entry: black
language: python
language_version: python3
types: [python]
- id: black
name: black
entry: black
language: python
language_version: python3
types: [python]
3 changes: 1 addition & 2 deletions src/prefect/agent/docker/agent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import multiprocessing
from sys import platform
from typing import Iterable, List, TYPE_CHECKING
from typing import TYPE_CHECKING, Iterable, List

from prefect import config, context
from prefect.agent import Agent
from prefect.environments.storage import Docker
from prefect.serialization.storage import StorageSchema
from prefect.utilities.graphql import GraphQLResult


if TYPE_CHECKING:
import docker

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/engine/executors/dask.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import uuid
from contextlib import contextmanager
from typing import Any, Callable, Iterator, List, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable, Iterator, List

from prefect import context
from prefect.engine.executors.base import Executor
Expand Down
1 change: 0 additions & 1 deletion src/prefect/engine/executors/sync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import warnings


from prefect.engine.executors.dask import LocalDaskExecutor


Expand Down
1 change: 0 additions & 1 deletion src/prefect/engine/result_handlers/result_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"""
from typing import Any


from prefect.utilities import logging


Expand Down
2 changes: 1 addition & 1 deletion src/prefect/environments/storage/bytes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict

import cloudpickle

Expand Down
3 changes: 1 addition & 2 deletions src/prefect/environments/storage/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import uuid
import warnings
from pathlib import PurePosixPath
from typing import Any, Callable, Dict, Iterable, List, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List

import cloudpickle
import pendulum
Expand All @@ -18,7 +18,6 @@
import prefect
from prefect.environments.storage import Storage


if TYPE_CHECKING:
import docker

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/environments/storage/local.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import socket
from typing import Any, Dict, List, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict, List

from slugify import slugify

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/environments/storage/memory.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict

import prefect
from prefect.engine.result_handlers import ResultHandler
Expand Down
2 changes: 1 addition & 1 deletion src/prefect/serialization/state.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, TYPE_CHECKING
from typing import TYPE_CHECKING, Any

from marshmallow import fields, post_load

Expand Down
2 changes: 1 addition & 1 deletion src/prefect/serialization/task.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Dict

from marshmallow import fields, post_load

Expand Down
3 changes: 1 addition & 2 deletions src/prefect/triggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ def task_c():
flow.run()
```
"""
from typing import Callable, Set, TYPE_CHECKING, Union

from typing import TYPE_CHECKING, Callable, Set, Union

from prefect import context
from prefect.engine import signals
Expand Down
3 changes: 1 addition & 2 deletions src/prefect/utilities/executors.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from concurrent.futures import ThreadPoolExecutor
from concurrent.futures import TimeoutError as FutureTimeout
from functools import wraps
from typing import Any, Callable, List, TYPE_CHECKING, Union

from typing import TYPE_CHECKING, Any, Callable, List, Union

import prefect

Expand Down
4 changes: 2 additions & 2 deletions tests/engine/cloud/test_cloud_task_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import tempfile
import time
import uuid
from box import Box
from unittest.mock import MagicMock

import cloudpickle
import pytest
import requests
from box import Box

import prefect
from prefect.client import Client
Expand All @@ -27,10 +27,10 @@
ClientFailed,
Failed,
Finished,
Queued,
Mapped,
Paused,
Pending,
Queued,
Retrying,
Running,
Skipped,
Expand Down

0 comments on commit f3d2007

Please sign in to comment.