Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds ruff, a drop-in replacement for black #423

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# isort: skip_file
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# isort: skip_file

I don't think this is needed

.venv
__pycache__
/build
Expand Down
1,613 changes: 846 additions & 767 deletions poetry.lock
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am worried a lot of things changed in here inadvertently and am also worried that by not using an older version of Poetry we may be forcing users to upgrade (which has its own issues at the moment)

Large diffs are not rendered by default.

11 changes: 3 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ types-protobuf = ">=3.20"
typing-extensions = "^4.2.0"

[tool.poetry.dev-dependencies]
black = "^23.1.0"
ruff = "^0.1.5"
cibuildwheel = "^2.11.0"
grpcio-tools = "^1.48.0"
isort = "^5.11.5"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
isort = "^5.11.5"

Expand All @@ -68,12 +68,11 @@ grpc = ["grpcio"]
build-develop = "python scripts/setup_bridge.py develop"
build-develop-with-release = { cmd = "python scripts/setup_bridge.py develop", env = { TEMPORAL_BUILD_RELEASE = "1" }}
fix-wheel = "python scripts/fix_wheel.py"
format = [{cmd = "black ."}, {cmd = "isort ."}]
format = [{cmd = "ruff format ."}]
gen-docs = "python scripts/gen_docs.py"
gen-protos = "python scripts/gen_protos.py"
lint = [
{cmd = "black --check ."},
{cmd = "isort --check-only ."},
{cmd = "ruff check ."},
{ref = "lint-types"},
{ref = "lint-docs"},
]
Expand Down Expand Up @@ -117,10 +116,6 @@ build-verbosity = "1"
before-all = "curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain stable -y && yum install -y openssl-devel"
environment = { PATH = "$PATH:$HOME/.cargo/bin", CARGO_NET_GIT_FETCH_WITH_CLI = "true" }

[tool.isort]
profile = "black"
skip_gitignore = true

[tool.mypy]
ignore_missing_imports = true
exclude = [
Expand Down
10 changes: 5 additions & 5 deletions scripts/gen_protos.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import tempfile
from functools import partial
from pathlib import Path
from typing import List, Mapping, Optional
from typing import List, Mapping

base_dir = Path(__file__).parent.parent
proto_dir = base_dir / "temporalio" / "bridge" / "sdk-core" / "protos"
Expand All @@ -22,8 +22,8 @@
v
for v in proto_dir.glob("**/*.proto")
if not str(v).startswith(str(testsrv_proto_dir / "dependencies"))
and not "health" in str(v)
and not "google" in str(v)
and "health" not in str(v)
and "google" not in str(v)
]
proto_paths.extend(test_proto_dir.glob("**/*.proto"))
proto_paths.extend(additional_proto_dir.glob("**/*.proto"))
Expand Down Expand Up @@ -92,7 +92,7 @@ def fix_generated_output(base_path: Path):
message_names = sorted(message_names)
if message_names:
f.write(
f'\n__all__ = [\n "' + '",\n "'.join(message_names) + '",\n]\n'
'\n__all__ = [\n "' + '",\n "'.join(message_names) + '",\n]\n'
)
# gRPC imports
if "service_pb2_grpc" in imports:
Expand All @@ -112,7 +112,7 @@ def fix_generated_output(base_path: Path):
message_names.append(message)
# __all__
message_names = sorted(message_names)
f.write(f' __all__.extend(["' + '", "'.join(message_names) + '"])\n')
f.write(' __all__.extend(["' + '", "'.join(message_names) + '"])\n')
f.write("except ImportError:\n pass")


Expand Down
5 changes: 3 additions & 2 deletions temporalio/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ def in_activity() -> bool:
Returns:
True if in an activity, False otherwise.
"""
return not _current_context.get(None) is None
return _current_context.get(None) is not None


def info() -> Info:
Expand Down Expand Up @@ -524,7 +524,8 @@ def _apply_to_callable(
fn=fn,
# iscoroutinefunction does not return true for async __call__
# TODO(cretz): Why can't MyPy handle this?
is_async=inspect.iscoroutinefunction(fn) or inspect.iscoroutinefunction(fn.__call__), # type: ignore
is_async=inspect.iscoroutinefunction(fn)
or inspect.iscoroutinefunction(fn.__call__), # type: ignore
no_thread_cancel_exception=no_thread_cancel_exception,
),
)
Expand Down
29 changes: 7 additions & 22 deletions temporalio/api/batch/v1/message_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 1 addition & 16 deletions temporalio/api/cluster/v1/message_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion temporalio/api/cluster/v1/message_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc
Loading
Loading