Skip to content

Commit e5e9f7b

Browse files
authored
[Feature] Code style and CI process updates (#39)
* style: update something * docs: update README.md * docs: update PR template * docs: update samples
1 parent 9bab773 commit e5e9f7b

Some content is hidden

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

63 files changed

+570
-666
lines changed

.flake8

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
## What is the purpose of the change
22

3+
<!-- Please provide the Issue number and link corresponding to the PR. -->
4+
ISSUE: [#issue_number](issue_link)
35

46

57
## Brief changelog

.github/workflows/license-check.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: License Template Check
2+
3+
on: [push, pull_request]
4+
5+
6+
jobs:
7+
license-check:
8+
runs-on: ubuntu-latest
9+
permissions: write-all
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Java
14+
uses: actions/setup-java@v4
15+
with:
16+
distribution: 'temurin'
17+
java-version: '11'
18+
- name: Check License Header
19+
run: bash ./scripts/check_license.sh

.github/workflows/python-lint-and-license-check.yml

Lines changed: 0 additions & 31 deletions
This file was deleted.

.github/workflows/python-lint.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Lint Python Code
2+
on: [push, pull_request]
3+
jobs:
4+
build:
5+
runs-on: ubuntu-latest
6+
steps:
7+
- uses: actions/checkout@v4
8+
- name: Install Python
9+
uses: actions/setup-python@v5
10+
with:
11+
python-version: "3.11"
12+
- name: Install dependencies
13+
run: |
14+
python -m pip install --upgrade pip
15+
pip install -r requirements.txt
16+
pip install ruff
17+
- name: Run Ruff
18+
run: ruff check --output-format=github . --config=pyproject.toml

.github/workflows/unittest.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

.license-ignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This file is used to ignore files and directories from the license scan
2+
# Note: these patterns are applied to single files or directories, not full paths
3+
4+
# file extensions
5+
.*md
6+
.*proto
7+
8+
# files
9+
.asf.yaml
10+
LICENSE
11+
NOTICE
12+
README.md
13+
requirements.txt
14+
rat-report.txt
15+
16+
# directories
17+
.vscode
18+
.idea
19+
.github
20+
.gitignore
21+
.license-ignore
22+
./samples/proto/*
23+
24+

.licenserc.yaml

Lines changed: 0 additions & 71 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# Apache Dubbo for python
1+
# Apache Dubbo for Python
22

33
![License](https://img.shields.io/github/license/apache/dubbo-python)
4+
![GitHub last commit](https://img.shields.io/github/last-commit/apache/dubbo-python)
5+
![GitHub branch check runs](https://img.shields.io/github/check-runs/apache/dubbo-python/main)
46

57
---
68

@@ -21,7 +23,7 @@ Visit [the official website](https://dubbo.apache.org/) for more information.
2123
## Features
2224

2325
- **Service Discovery**: Zookeeper
24-
- **Load Balance**: Random
26+
- **Load Balance**: Random, CPU
2527
- **RPC Protocols**: Triple(gRPC compatible and HTTP-friendly)
2628
- **Transport**: asyncio(uvloop)
2729
- **Serialization**: Customizable(protobuf, json...)

dubbo/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@
1717
from .bootstrap import Dubbo
1818
from .client import Client
1919
from .server import Server
20-
from .__version__ import __version__
2120

2221
__all__ = ["Dubbo", "Client", "Server"]

dubbo/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040

4141

4242
class Client:
43-
4443
def __init__(self, reference: ReferenceConfig, dubbo: Optional[Dubbo] = None):
4544
self._initialized = False
4645
self._global_lock = threading.RLock()

dubbo/cluster/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
# limitations under the License.
1616

1717
from ._interfaces import Cluster, Directory, LoadBalance
18+
19+
__all__ = ["Cluster", "Directory", "LoadBalance"]

dubbo/cluster/failfast_cluster.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def __init__(self, directory, url: URL):
3939
self._load_balance.set_monitor(directory)
4040

4141
def invoke(self, invocation) -> Result:
42-
4342
# get the invokers
4443
invokers = self._directory.list(invocation)
4544
if not invokers:

dubbo/cluster/monitor/cpu.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,5 +172,7 @@ def get_cpu_usage(interval) -> bytes:
172172
:return: The CPU usage.
173173
:rtype: bytes
174174
"""
175-
float_value = CpuUtils.get_total_cpu_usage(interval=int(interval.decode("utf-8")))
175+
float_value = CpuUtils.get_total_cpu_usage(
176+
interval=int(interval.decode("utf-8"))
177+
)
176178
return str(float_value).encode("utf-8")

dubbo/extension/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@
1717
from dubbo.extension.extension_loader import ExtensionError
1818
from dubbo.extension.extension_loader import ExtensionLoader as _ExtensionLoader
1919

20+
__all__ = ["ExtensionError", "extensionLoader"]
21+
2022
extensionLoader = _ExtensionLoader()

dubbo/loadbalance/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@
1515
# limitations under the License.
1616

1717
from ._interfaces import AbstractLoadBalance, LoadBalance
18+
19+
__all__ = ["AbstractLoadBalance", "LoadBalance"]

dubbo/protocol/_interfaces.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525

2626
class Invocation(abc.ABC):
27-
2827
@abc.abstractmethod
2928
def get_service_name(self) -> str:
3029
"""
@@ -103,7 +102,6 @@ def invoke(self, invocation: Invocation) -> Result:
103102

104103

105104
class Protocol(abc.ABC):
106-
107105
@abc.abstractmethod
108106
def export(self, url: URL):
109107
"""

dubbo/protocol/triple/call/server_call.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343

4444

4545
class TripleServerCall(ServerCall, ServerStream.Listener):
46-
4746
def __init__(
4847
self,
4948
stream: ServerStream,
@@ -172,7 +171,6 @@ def __init__(
172171
client_stream: bool,
173172
server_stream: bool,
174173
):
175-
176174
self._server_call: TripleServerCall = server_call
177175
self._func = func
178176

dubbo/protocol/triple/coders.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ def _process_payload(self) -> None:
241241
self._state = HEADER
242242

243243
class Listener(abc.ABC):
244-
245244
@abc.abstractmethod
246245
def on_message(self, message: bytes):
247246
"""

dubbo/protocol/triple/protocol.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import functools
1818
import uuid
19+
from collections.abc import Iterable
1920
from concurrent.futures import ThreadPoolExecutor
2021
from typing import Dict, Optional
2122

@@ -63,7 +64,7 @@ def export(self, url: URL):
6364

6465
service_handler = url.attributes[common_constants.SERVICE_HANDLER_KEY]
6566

66-
if iter(service_handler):
67+
if isinstance(service_handler, Iterable):
6768
for handler in service_handler:
6869
self._path_resolver[handler.service_name] = handler
6970
else:

dubbo/protocol/triple/stream/server_stream.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242

4343
class TripleServerStream(ServerStream):
44-
4544
def __init__(self, stream: Http2Stream):
4645
self._stream = stream
4746

dubbo/proxy/_interfaces.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424

2525

2626
class RpcCallable(abc.ABC):
27-
2827
@abc.abstractmethod
2928
def __call__(self, *args, **kwargs):
3029
"""
@@ -34,7 +33,6 @@ def __call__(self, *args, **kwargs):
3433

3534

3635
class RpcCallableFactory(abc.ABC):
37-
3836
@abc.abstractmethod
3937
def get_callable(self, invoker: Invoker, url: URL) -> RpcCallable:
4038
"""

dubbo/registry/_interfaces.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ def notify(self, urls: List[URL]) -> None:
3939

4040

4141
class Registry(Node, abc.ABC):
42-
4342
@abc.abstractmethod
4443
def register(self, url: URL) -> None:
4544
"""
@@ -94,7 +93,6 @@ def lookup(self, url: URL) -> None:
9493

9594

9695
class RegistryFactory(abc.ABC):
97-
9896
@abc.abstractmethod
9997
def get_registry(self, url: URL) -> Registry:
10098
"""

0 commit comments

Comments
 (0)