Skip to content

Commit 38d9eef

Browse files
authored
Use ruff to auto-format code and sort imports. (#566)
* Use ruff to format and sort imports
1 parent 7ac4445 commit 38d9eef

File tree

139 files changed

+1934
-1892
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+1934
-1892
lines changed

poetry.lock

Lines changed: 29 additions & 179 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ script = "build.py"
2424
# a setup file, but we are using setuptools Rust manually in our build.py which
2525
# needs a setup file.
2626
# TODO(cretz): Find a way to not require a setup file since that is going away
27-
# at some point in Poetry. Revisit Maturin or fine some other approach.
27+
# at some point in Poetry. Revisit Maturin or find some other approach.
2828
generate-setup-file = true
2929

3030
[tool.poetry.urls]
@@ -41,10 +41,8 @@ types-protobuf = ">=3.20"
4141
typing-extensions = "^4.2.0"
4242

4343
[tool.poetry.dev-dependencies]
44-
black = "^23.1.0"
4544
cibuildwheel = "^2.17.0"
4645
grpcio-tools = "^1.48.0"
47-
isort = "^5.11.5"
4846
mypy = "^1.0.0"
4947
mypy-protobuf = "^3.3.0"
5048
psutil = "^5.9.3"
@@ -54,6 +52,7 @@ pydoctor = "^23.4.1"
5452
pytest = "^7.4"
5553
pytest-asyncio = "^0.21"
5654
pytest-timeout = "^2.2"
55+
ruff = "^0.5.0"
5756
setuptools = ">=65.0.0"
5857
setuptools-rust = ">=1.3.0"
5958
toml = "^0.10.2"
@@ -64,16 +63,19 @@ wheel = "^0.42.0"
6463
opentelemetry = ["opentelemetry-api", "opentelemetry-sdk"]
6564
grpc = ["grpcio"]
6665

66+
[tool.poetry.group.dev.dependencies]
67+
ruff = "^0.5.0"
68+
6769
[tool.poe.tasks]
6870
build-develop = "python scripts/setup_bridge.py develop"
6971
build-develop-with-release = { cmd = "python scripts/setup_bridge.py develop", env = { TEMPORAL_BUILD_RELEASE = "1" }}
7072
fix-wheel = "python scripts/fix_wheel.py"
71-
format = [{cmd = "black ."}, {cmd = "isort ."}]
73+
format = [{cmd = "ruff check --select I --fix"}, {cmd = "ruff format"}, ]
7274
gen-docs = "python scripts/gen_docs.py"
7375
gen-protos = "python scripts/gen_protos.py"
7476
lint = [
75-
{cmd = "black --check ."},
76-
{cmd = "isort --check-only ."},
77+
{cmd = "ruff check --select I"},
78+
{cmd = "ruff format --check"},
7779
{ref = "lint-types"},
7880
{ref = "lint-docs"},
7981
]
@@ -125,11 +127,6 @@ build-verbosity = "1"
125127
before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
126128
environment = { PATH = "$PATH:$HOME/.cargo/bin", CARGO_NET_GIT_FETCH_WITH_CLI = "true" }
127129

128-
[tool.isort]
129-
profile = "black"
130-
skip_gitignore = true
131-
extend_skip = ["./temporalio/bridge/sdk-core", "./temporalio/bridge/target"]
132-
133130
[tool.mypy]
134131
ignore_missing_imports = true
135132
exclude = [
@@ -177,6 +174,9 @@ privacy = [
177174
project-name = "Temporal Python"
178175
sidebar-expand-depth = 2
179176

177+
[tool.ruff]
178+
target-version = "py38"
179+
180180
[build-system]
181181
build-backend = "poetry.core.masonry.api"
182182
requires = ["poetry-core>=1.0.0", "setuptools", "wheel", "setuptools-rust", "protoc-wheel-0"]

temporalio/activity.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,19 @@
4141

4242

4343
@overload
44-
def defn(fn: CallableType) -> CallableType:
45-
...
44+
def defn(fn: CallableType) -> CallableType: ...
4645

4746

4847
@overload
4948
def defn(
5049
*, name: Optional[str] = None, no_thread_cancel_exception: bool = False
51-
) -> Callable[[CallableType], CallableType]:
52-
...
50+
) -> Callable[[CallableType], CallableType]: ...
5351

5452

5553
@overload
5654
def defn(
5755
*, no_thread_cancel_exception: bool = False, dynamic: bool = False
58-
) -> Callable[[CallableType], CallableType]:
59-
...
56+
) -> Callable[[CallableType], CallableType]: ...
6057

6158

6259
def defn(
@@ -364,7 +361,7 @@ async def wait_for_worker_shutdown() -> None:
364361

365362

366363
def wait_for_worker_shutdown_sync(
367-
timeout: Optional[Union[timedelta, float]] = None
364+
timeout: Optional[Union[timedelta, float]] = None,
368365
) -> None:
369366
"""Synchronously block while waiting for shutdown to be called on the
370367
worker.
@@ -539,7 +536,8 @@ def _apply_to_callable(
539536
fn=fn,
540537
# iscoroutinefunction does not return true for async __call__
541538
# TODO(cretz): Why can't MyPy handle this?
542-
is_async=inspect.iscoroutinefunction(fn) or inspect.iscoroutinefunction(fn.__call__), # type: ignore
539+
is_async=inspect.iscoroutinefunction(fn)
540+
or inspect.iscoroutinefunction(fn.__call__), # type: ignore
543541
no_thread_cancel_exception=no_thread_cancel_exception,
544542
),
545543
)

temporalio/api/batch/v1/message_pb2.py

Lines changed: 7 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporalio/api/batch/v1/message_pb2.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2323
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
THE SOFTWARE.
2525
"""
26+
2627
import builtins
28+
import sys
29+
2730
import google.protobuf.descriptor
2831
import google.protobuf.message
2932
import google.protobuf.timestamp_pb2
30-
import sys
33+
3134
import temporalio.api.common.v1.message_pb2
3235
import temporalio.api.enums.v1.batch_operation_pb2
3336
import temporalio.api.enums.v1.reset_pb2

temporalio/api/cluster/v1/message_pb2.py

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

temporalio/api/cluster/v1/message_pb2.pyi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2323
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
THE SOFTWARE.
2525
"""
26+
2627
import builtins
2728
import collections.abc
29+
import sys
30+
2831
import google.protobuf.descriptor
2932
import google.protobuf.internal.containers
3033
import google.protobuf.message
3134
import google.protobuf.timestamp_pb2
32-
import sys
35+
3336
import temporalio.api.enums.v1.cluster_pb2
3437
import temporalio.api.enums.v1.common_pb2
3538
import temporalio.api.version.v1.message_pb2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
22
"""Client and server classes corresponding to protobuf-defined services."""
3+
34
import grpc

0 commit comments

Comments
 (0)