Skip to content

Commit 87cb779

Browse files
committed
Code Formatting
1 parent aff0858 commit 87cb779

File tree

103 files changed

+278
-597
lines changed

Some content is hidden

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

103 files changed

+278
-597
lines changed

pyproject.toml

Lines changed: 35 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -15,88 +15,47 @@
1515
# limitations under the License.
1616

1717

18-
## ruff settings ##
19-
[tool.ruff]
20-
# Exclude a variety of commonly ignored directories.
21-
exclude = [
22-
".bzr",
23-
".direnv",
24-
".eggs",
25-
".git",
26-
".git-rewrite",
27-
".hg",
28-
".ipynb_checkpoints",
29-
".mypy_cache",
30-
".nox",
31-
".pants.d",
32-
".pyenv",
33-
".pytest_cache",
34-
".pytype",
35-
".ruff_cache",
36-
".svn",
37-
".tox",
38-
".venv",
39-
".vscode",
40-
"__pypackages__",
41-
"_build",
42-
"buck-out",
43-
"build",
44-
"dist",
45-
"node_modules",
46-
"site-packages",
47-
"venv",
48-
"samples/proto",
49-
]
50-
51-
# Same as Black.
52-
line-length = 88
53-
indent-width = 4
18+
### Ruff settings ###
5419

55-
target-version = "py38"
56-
57-
[tool.ruff.lint]
58-
# Enable Pyflakes (`F`) and a subset of the pycodestyle (`E`) codes by default.
59-
# Unlike Flake8, Ruff doesn't enable pycodestyle warnings (`W`) or
60-
# McCabe complexity (`C901`) by default.
61-
select = ["E4", "E7", "E9", "F"]
62-
ignore = []
63-
64-
# Allow fix for all enabled rules (when `--fix`) is provided.
65-
fixable = ["ALL"]
66-
unfixable = []
67-
68-
# Allow unused variables when underscore-prefixed.
69-
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
20+
# Top-level
21+
[tool.ruff]
22+
target-version = "py39"
23+
line-length = 120
24+
extend-exclude = ["samples/proto"]
7025

26+
# Format
7127
[tool.ruff.format]
72-
# Like Black, use double quotes for strings.
73-
quote-style = "double"
74-
75-
# Like Black, indent with spaces, rather than tabs.
76-
indent-style = "space"
28+
docstring-code-format = true
7729

78-
# Like Black, respect magic trailing commas.
79-
skip-magic-trailing-comma = false
30+
# Lint
31+
[tool.ruff.lint]
32+
select = [
33+
"E", # pycodestyle errors
34+
"W", # pycodestyle warnings
35+
"F", # pyflakes
36+
"I", # Check for missing imports (auto-fixable)
37+
"UP", # pyupgrade
38+
"ASYNC", # flake8-async
39+
"ISC", # Checks for implicit literal string concatenation (auto-fixable)
40+
"LOG", # Checking the use of logging objects
41+
"G", # Check for logging format issues (auto-fixable)
42+
]
43+
ignore = [
44+
"ISC001" # may casue conflict with ruff
45+
]
8046

81-
# Like Black, automatically detect the appropriate line ending.
82-
line-ending = "auto"
8347

84-
# Enable auto-formatting of code examples in docstrings. Markdown,
85-
# reStructuredText code/literal blocks and doctests are all supported.
86-
docstring-code-format = true
48+
[tool.ruff.lint.isort]
49+
combine-as-imports = true
8750

88-
# Set the line length limit used when formatting code snippets in
89-
# docstrings.
90-
#
91-
# This only has an effect when the `docstring-code-format` setting is
92-
# enabled.
93-
docstring-code-line-length = "dynamic"
51+
section-order = [
52+
"future",
53+
"standard-library",
54+
"third-party",
55+
"first-party",
56+
"local-folder"
57+
]
9458

9559

96-
## pytest settings ##
97-
[tool.pytest.ini_options]
98-
addopts = [
99-
"-ra",
100-
"-p", "no:warnings"
101-
]
102-
testpaths = ["tests"]
60+
[tool.mypy]
61+
files = "src"

samples/helloworld/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def say_hello(self, message: bytes) -> bytes:
2727

2828
if __name__ == "__main__":
2929
# Create a client
30-
reference_config = ReferenceConfig.from_url(
31-
"tri://127.0.0.1:50051/org.apache.dubbo.samples.HelloWorld"
32-
)
30+
reference_config = ReferenceConfig.from_url("tri://127.0.0.1:50051/org.apache.dubbo.samples.HelloWorld")
3331
dubbo_client = dubbo.Client(reference_config)
3432
unary_service_stub = UnaryServiceStub(dubbo_client)
3533

samples/helloworld/server.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ def say_hello(self, message: bytes) -> bytes:
2626

2727
def build_service_handler():
2828
# build a method handler
29-
method_handler = RpcMethodHandler.unary(
30-
method=UnaryServiceServicer().say_hello, method_name="unary"
31-
)
29+
method_handler = RpcMethodHandler.unary(method=UnaryServiceServicer().say_hello, method_name="unary")
3230
# build a service handler
3331
service_handler = RpcServiceHandler(
3432
service_name="org.apache.dubbo.samples.HelloWorld",
@@ -40,9 +38,7 @@ def build_service_handler():
4038
if __name__ == "__main__":
4139
# build service config
4240
service_handler = build_service_handler()
43-
service_config = ServiceConfig(
44-
service_handler=service_handler, host="127.0.0.1", port=50051
45-
)
41+
service_config = ServiceConfig(service_handler=service_handler, host="127.0.0.1", port=50051)
4642
# start the server
4743
server = dubbo.Server(service_config).start()
4844

samples/registry/zookeeper/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ def say_hello(self, request):
3535
registry_config = RegistryConfig.from_url("zookeeper://127.0.0.1:2181")
3636
bootstrap = dubbo.Dubbo(registry_config=registry_config)
3737

38-
reference_config = ReferenceConfig(
39-
protocol="tri", service="org.apache.dubbo.samples.data.Greeter"
40-
)
38+
reference_config = ReferenceConfig(protocol="tri", service="org.apache.dubbo.samples.data.Greeter")
4139
dubbo_client = bootstrap.create_client(reference_config)
4240

4341
stub = GreeterServiceStub(dubbo_client)

samples/serialization/json/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def say_hello(self, name: str, age: int):
4242

4343

4444
if __name__ == "__main__":
45-
reference_config = ReferenceConfig.from_url(
46-
"tri://127.0.0.1:50051/org.apache.dubbo.samples.serialization.json"
47-
)
45+
reference_config = ReferenceConfig.from_url("tri://127.0.0.1:50051/org.apache.dubbo.samples.serialization.json")
4846
dubbo_client = dubbo.Client(reference_config)
4947

5048
stub = GreeterServiceStub(dubbo_client)

samples/serialization/json/server.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16-
from typing import Tuple
1716

1817
import orjson
1918

@@ -22,7 +21,7 @@
2221
from dubbo.proxy.handlers import RpcMethodHandler, RpcServiceHandler
2322

2423

25-
def request_deserializer(data: bytes) -> Tuple[str, int]:
24+
def request_deserializer(data: bytes) -> tuple[str, int]:
2625
json_dict = orjson.loads(data)
2726
return json_dict["name"], json_dict["age"]
2827

@@ -57,9 +56,7 @@ def build_service_handler():
5756
if __name__ == "__main__":
5857
# build server config
5958
service_handler = build_service_handler()
60-
service_config = ServiceConfig(
61-
service_handler=service_handler, host="127.0.0.1", port=50051
62-
)
59+
service_config = ServiceConfig(service_handler=service_handler, host="127.0.0.1", port=50051)
6360

6461
# start the server
6562
server = dubbo.Server(service_config).start()

samples/serialization/protobuf/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,7 @@ def say_hello(self, request):
3131

3232

3333
if __name__ == "__main__":
34-
reference_config = ReferenceConfig.from_url(
35-
"tri://127.0.0.1:50051/org.apache.dubbo.samples.data.Greeter"
36-
)
34+
reference_config = ReferenceConfig.from_url("tri://127.0.0.1:50051/org.apache.dubbo.samples.data.Greeter")
3735
dubbo_client = dubbo.Client(reference_config)
3836

3937
stub = GreeterServiceStub(dubbo_client)

samples/serialization/protobuf/server.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,7 @@ def build_service_handler():
4444
if __name__ == "__main__":
4545
# build a service handler
4646
service_handler = build_service_handler()
47-
service_config = ServiceConfig(
48-
service_handler=service_handler, host="127.0.0.1", port=50051
49-
)
47+
service_config = ServiceConfig(service_handler=service_handler, host="127.0.0.1", port=50051)
5048

5149
# start the server
5250
server = dubbo.Server(service_config).start()

samples/stream/bidi_stream/client.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ def bi_stream(self, *args):
3434

3535
if __name__ == "__main__":
3636
# Create a reference config
37-
reference_config = ReferenceConfig.from_url(
38-
"tri://127.0.0.1:50051/org.apache.dubbo.samples.data.Greeter"
39-
)
37+
reference_config = ReferenceConfig.from_url("tri://127.0.0.1:50051/org.apache.dubbo.samples.data.Greeter")
4038
dubbo_client = dubbo.Client(reference_config)
4139
stub = GreeterServiceStub(dubbo_client)
4240

samples/stream/bidi_stream/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
import time
17+
1618
import dubbo
1719
from dubbo.configs import ServiceConfig
1820
from dubbo.proxy.handlers import RpcMethodHandler, RpcServiceHandler
1921
from samples.proto import greeter_pb2
2022

21-
import time
22-
2323

2424
class GreeterServiceServicer:
2525
def bi_stream(self, stream):

0 commit comments

Comments
 (0)