Skip to content

Commit

Permalink
Fix import sorting (PrefectHQ#10312)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Aug 21, 2023
1 parent ba966eb commit 1110003
Show file tree
Hide file tree
Showing 112 changed files with 319 additions and 327 deletions.
5 changes: 5 additions & 0 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
src = ["src"]

# Use Ruff for sorting imports
extend-select = ["I"]

# Do not enforce line length; black does this for code and we do not care about comments / docs
ignore = ["E501"]

Expand Down
1 change: 1 addition & 0 deletions benches/bench_cli.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess

from pytest_benchmark.fixture import BenchmarkFixture


Expand Down
1 change: 1 addition & 0 deletions benches/bench_import.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import subprocess

from pytest_benchmark.fixture import BenchmarkFixture


Expand Down
4 changes: 3 additions & 1 deletion flows/worker.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os
import prefect
import subprocess
import sys

from packaging.version import Version

import prefect


# Checks to make sure that collections are loaded prior to attempting to start a worker
def main():
Expand Down
1 change: 0 additions & 1 deletion scripts/wait-for-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

from prefect import get_client


DEFAULT_TIMEOUT_SECONDS = 120


Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from setuptools import find_packages, setup

import versioneer
from setuptools import find_packages, setup

install_requires = open("requirements.txt").read().strip().split("\n")
dev_requires = open("requirements-dev.txt").read().strip().split("\n")
Expand Down
19 changes: 9 additions & 10 deletions src/prefect/_internal/concurrency/calls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,24 @@
import dataclasses
import inspect
import threading
from concurrent.futures._base import (
CANCELLED,
CANCELLED_AND_NOTIFIED,
FINISHED,
RUNNING,
)
from typing import Any, Awaitable, Callable, Dict, Generic, Optional, Tuple, TypeVar

from typing_extensions import ParamSpec

from prefect._internal.concurrency.event_loop import get_running_loop
from prefect._internal.concurrency import logger
from prefect._internal.concurrency.cancellation import (
CancelledError,
cancel_async_at,
get_deadline,
cancel_sync_at,
get_deadline,
)
from concurrent.futures._base import (
CANCELLED,
CANCELLED_AND_NOTIFIED,
FINISHED,
RUNNING,
)
from prefect._internal.concurrency import logger

from prefect._internal.concurrency.event_loop import get_running_loop

T = TypeVar("T")
P = ParamSpec("P")
Expand Down
10 changes: 5 additions & 5 deletions src/prefect/_internal/concurrency/cancellation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
Utilities for cancellation in synchronous and asynchronous contexts.
"""

import abc
import asyncio
import contextlib
import ctypes
import os
import abc
import math
import os
import signal
import anyio
import sys
import threading
import time
from typing import Callable, Optional, Type, Dict
from typing import Callable, Dict, Optional, Type

import anyio

from prefect._internal.concurrency.event_loop import get_running_loop
from prefect._internal.concurrency import logger
from prefect._internal.concurrency.event_loop import get_running_loop

_THREAD_SHIELDS: Dict[threading.Thread, "ThreadShield"] = {}
_THREAD_SHIELDS_LOCK = threading.Lock()
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/_internal/concurrency/inspection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Utilities for inspection of stack frames and threads.
"""

from types import FrameType
import dis
import linecache
import sys
import threading
import dis
from types import FrameType
from typing import List

"""
Expand Down
4 changes: 2 additions & 2 deletions src/prefect/_internal/concurrency/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@

from typing_extensions import Self

from prefect._internal.concurrency import logger
from prefect._internal.concurrency.api import create_call, from_sync
from prefect._internal.concurrency.cancellation import get_deadline, get_timeout
from prefect._internal.concurrency.event_loop import get_running_loop
from prefect._internal.concurrency.threads import WorkerThread, get_global_loop
from prefect._internal.concurrency.cancellation import get_deadline, get_timeout
from prefect._internal.concurrency import logger

T = TypeVar("T")

Expand Down
4 changes: 2 additions & 2 deletions src/prefect/_internal/concurrency/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
import threading
from typing import List, Optional

from prefect._internal.concurrency import logger
from prefect._internal.concurrency.calls import Call, Portal
from prefect._internal.concurrency.cancellation import CancelledError
from prefect._internal.concurrency.event_loop import get_running_loop
from prefect._internal.concurrency.primitives import Event
from prefect._internal.concurrency.cancellation import CancelledError
from prefect._internal.concurrency import logger


class WorkerThread(Portal):
Expand Down
6 changes: 3 additions & 3 deletions src/prefect/_internal/concurrency/waiters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
import abc
import asyncio
import contextlib
from collections import deque
import inspect
import weakref
import queue
import threading
import weakref
from collections import deque
from typing import Awaitable, Generic, List, Optional, TypeVar, Union

import anyio

from prefect._internal.concurrency import logger
from prefect._internal.concurrency.calls import Call, Portal
from prefect._internal.concurrency.event_loop import call_soon_in_loop
from prefect._internal.concurrency.primitives import Event
from prefect._internal.concurrency import logger

T = TypeVar("T")

Expand Down
1 change: 0 additions & 1 deletion src/prefect/artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from prefect.context import FlowRunContext, TaskRunContext
from prefect.utilities.asyncutils import sync_compatible


INVALID_TABLE_TYPE_ERROR = (
"`create_table_artifact` requires a `table` argument of type `dict[list]` or"
" `list[dict]`."
Expand Down
43 changes: 18 additions & 25 deletions src/prefect/cli/_prompts.py
Original file line number Diff line number Diff line change
@@ -1,43 +1,36 @@
"""
Utilities for prompting the user for input
"""
from datetime import timedelta
from getpass import GetPassWarning
import os
import shutil
import sys
from prefect.deployments.base import _search_for_flow_functions
from prefect.flows import load_flow_from_entrypoint
from prefect.infrastructure.container import DockerRegistry
from prefect.utilities.processutils import run_process
from rich.prompt import PromptBase, InvalidResponse
from rich.text import Text
from datetime import timedelta
from getpass import GetPassWarning
from typing import Any, Dict, List, Optional

import readchar
from rich.console import Console, Group
from rich.live import Live
from rich.progress import Progress, SpinnerColumn, TextColumn
from rich.prompt import Confirm, InvalidResponse, Prompt, PromptBase
from rich.table import Table
from rich.text import Text

from prefect.cli._utilities import exit_with_error
from prefect.client.collections import get_collections_metadata_client
from prefect.client.orchestration import PrefectClient
from prefect.client.schemas.actions import WorkPoolCreate
from prefect.client.schemas.schedules import (
SCHEDULE_TYPES,
CronSchedule,
IntervalSchedule,
RRuleSchedule,
)

from typing import Any, Dict, List, Optional
import readchar

from rich.console import Console, Group
from rich.table import Table
from rich.live import Live
from rich.prompt import Prompt, Confirm
from prefect.cli._utilities import exit_with_error

from prefect.client.utilities import inject_client

from prefect.client.orchestration import PrefectClient

from prefect.client.collections import get_collections_metadata_client

from prefect.client.schemas.actions import WorkPoolCreate

from prefect.deployments.base import _search_for_flow_functions
from prefect.flows import load_flow_from_entrypoint
from prefect.infrastructure.container import DockerRegistry
from prefect.utilities.processutils import run_process
from prefect.utilities.slugify import slugify


Expand Down
2 changes: 1 addition & 1 deletion src/prefect/cli/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
Custom Prefect CLI types
"""
import functools
import sys
from typing import List, Optional

import typer
import typer.core
import sys

from prefect._internal.compatibility.deprecated import generate_deprecation_message
from prefect.cli._utilities import with_cli_exception_handling
Expand Down
11 changes: 6 additions & 5 deletions src/prefect/cli/cloud/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
Command line interface for working with webhooks
"""

import typer
from typing import List, Dict
from typing import Dict, List
from uuid import UUID

import typer
from rich.table import Table

from prefect.cli._types import PrefectTyper
from prefect.cli.cloud import cloud_app, confirm_logged_in
from prefect.client.cloud import get_cloud_client
from prefect.cli._utilities import exit_with_error
from prefect.cli.cloud import cloud_app, confirm_logged_in
from prefect.cli.root import app
from prefect.client.cloud import get_cloud_client
from prefect.settings import PREFECT_API_URL
from rich.table import Table

webhook_app = PrefectTyper(
name="webhook", help="Commands for interacting with Prefect Cloud Webhooks"
Expand Down
58 changes: 25 additions & 33 deletions src/prefect/cli/deploy.py
Original file line number Diff line number Diff line change
@@ -1,71 +1,63 @@
"""Module containing implementation for deploying projects."""
from getpass import GetPassWarning
import json
import os
from copy import deepcopy
from datetime import timedelta
import os
from getpass import GetPassWarning
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from uuid import UUID

import typer
import typer.core
import yaml
from rich.panel import Panel
from rich.console import Console
from rich.panel import Panel

from prefect.cli._utilities import (
exit_with_error,
from prefect._internal.compatibility.deprecated import (
generate_deprecation_message,
)
from prefect.blocks.system import Secret
from prefect.cli._prompts import (
prompt,
confirm,
prompt_select_from_table,
prompt_schedule,
prompt_select_work_pool,
prompt_entrypoint,
prompt,
prompt_build_custom_docker_image,
prompt_entrypoint,
prompt_push_custom_docker_image,
prompt_schedule,
prompt_select_from_table,
prompt_select_work_pool,
)
from prefect.cli._utilities import (
exit_with_error,
)
from prefect.cli.root import app, is_interactive
from prefect.client.orchestration import PrefectClient, ServerType
from prefect.client.schemas.schedules import (
SCHEDULE_TYPES,
CronSchedule,
IntervalSchedule,
RRuleSchedule,
)
from prefect.client.utilities import inject_client
from prefect.events.schemas import DeploymentTrigger
from prefect.exceptions import ObjectNotFound
from prefect.flows import load_flow_from_entrypoint
from prefect.deployments import find_prefect_directory, register_flow
from prefect.settings import PREFECT_UI_URL, PREFECT_DEBUG_MODE
from prefect.utilities.asyncutils import run_sync_in_worker_thread
from prefect.utilities.callables import parameter_schema
from prefect.utilities.templating import apply_values

from prefect.deployments.steps.core import run_steps

from prefect.deployments.base import (
_copy_deployments_into_prefect_file,
_get_git_branch,
_get_git_remote_origin_url,
_save_deployment_to_prefect_file,
)

from prefect.blocks.system import Secret

from prefect.utilities.slugify import slugify

from prefect.client.orchestration import PrefectClient, ServerType

from prefect._internal.compatibility.deprecated import (
generate_deprecation_message,
)

from prefect.utilities.collections import get_from_dict

from prefect.deployments.steps.core import run_steps
from prefect.events.schemas import DeploymentTrigger
from prefect.exceptions import ObjectNotFound
from prefect.flows import load_flow_from_entrypoint
from prefect.settings import PREFECT_DEBUG_MODE, PREFECT_UI_URL
from prefect.utilities.annotations import NotSet
from prefect.utilities.asyncutils import run_sync_in_worker_thread
from prefect.utilities.callables import parameter_schema
from prefect.utilities.collections import get_from_dict
from prefect.utilities.slugify import slugify
from prefect.utilities.templating import apply_values


@app.command()
Expand Down
Loading

0 comments on commit 1110003

Please sign in to comment.