Skip to content

Commit 53ba8b4

Browse files
committed
style: apply black formatting to type-annotated files
1 parent 02f5ec8 commit 53ba8b4

File tree

9 files changed

+59
-14
lines changed

9 files changed

+59
-14
lines changed

paddleocr/_abstract.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
class CLISubcommandExecutor(metaclass=abc.ABCMeta):
2323
@abc.abstractmethod
24-
def add_subparser(self, subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
24+
def add_subparser(
25+
self, subparsers: argparse._SubParsersAction
26+
) -> argparse.ArgumentParser:
2527
raise NotImplementedError
2628

2729
@abc.abstractmethod

paddleocr/_common_args.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@
3333
from ._utils.cli import str2bool
3434

3535

36-
def parse_common_args(kwargs: dict[str, Any], *, default_enable_hpi: bool | None) -> dict[str, Any]:
36+
def parse_common_args(
37+
kwargs: dict[str, Any], *, default_enable_hpi: bool | None
38+
) -> dict[str, Any]:
3739
default_vals = {
3840
"device": DEFAULT_DEVICE,
3941
"enable_hpi": default_enable_hpi,
@@ -62,7 +64,9 @@ def parse_common_args(kwargs: dict[str, Any], *, default_enable_hpi: bool | None
6264
return kwargs
6365

6466

65-
def prepare_common_init_args(model_name: str | None, common_args: dict[str, Any]) -> dict[str, Any]:
67+
def prepare_common_init_args(
68+
model_name: str | None, common_args: dict[str, Any]
69+
) -> dict[str, Any]:
6670
device = common_args["device"]
6771
if device is None:
6872
device = get_default_device()
@@ -99,7 +103,12 @@ def prepare_common_init_args(model_name: str | None, common_args: dict[str, Any]
99103
return init_kwargs
100104

101105

102-
def add_common_cli_opts(parser: argparse.ArgumentParser, *, default_enable_hpi: bool | None, allow_multiple_devices: bool) -> None:
106+
def add_common_cli_opts(
107+
parser: argparse.ArgumentParser,
108+
*,
109+
default_enable_hpi: bool | None,
110+
allow_multiple_devices: bool,
111+
) -> None:
103112
if allow_multiple_devices:
104113
help_ = "Device(s) to use for inference, e.g., `cpu`, `gpu`, `npu`, `gpu:0`, `gpu:0,1`. If multiple devices are specified, inference will be performed in parallel. Note that parallel inference is not always supported. By default, GPU 0 will be used if available; otherwise, the CPU will be used."
105114
else:

paddleocr/_models/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ class PredictorCLISubcommandExecutor(CLISubcommandExecutor):
9393
def subparser_name(self) -> str:
9494
raise NotImplementedError
9595

96-
def add_subparser(self, subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
96+
def add_subparser(
97+
self, subparsers: argparse._SubParsersAction
98+
) -> argparse.ArgumentParser:
9799
subparser = subparsers.add_parser(name=self.subparser_name)
98100
self._update_subparser(subparser)
99101
subparser.add_argument("--model_name", type=str, help="Name of the model.")

paddleocr/_pipelines/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,9 @@ class PipelineCLISubcommandExecutor(CLISubcommandExecutor):
119119
def subparser_name(self) -> str:
120120
raise NotImplementedError
121121

122-
def add_subparser(self, subparsers: argparse._SubParsersAction) -> argparse.ArgumentParser:
122+
def add_subparser(
123+
self, subparsers: argparse._SubParsersAction
124+
) -> argparse.ArgumentParser:
123125
subparser = subparsers.add_parser(name=self.subparser_name)
124126
self._update_subparser(subparser)
125127
add_common_cli_opts(

paddleocr/_pipelines/paddleocr_vl.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,11 @@ def concatenate_markdown_pages(self, markdown_list: list[str]) -> str:
222222
return self.paddlex_pipeline.concatenate_markdown_pages(markdown_list)
223223

224224
def restructure_pages(
225-
self, res_list: list[Any], merge_tables: bool = True, relevel_titles: bool = True, concatenate_pages: bool = False
225+
self,
226+
res_list: list[Any],
227+
merge_tables: bool = True,
228+
relevel_titles: bool = True,
229+
concatenate_pages: bool = False,
226230
) -> list[Any]:
227231
return list(
228232
self.paddlex_pipeline.restructure_pages(

paddleocr/_pipelines/pp_chatocrv4_doc.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,21 @@ def __init__(
8888
def _paddlex_pipeline_name(self) -> str:
8989
return "PP-ChatOCRv4-doc"
9090

91-
def save_vector(self, vector_info: Any, save_path: str, retriever_config: dict[str, Any] | None = None) -> Any:
91+
def save_vector(
92+
self,
93+
vector_info: Any,
94+
save_path: str,
95+
retriever_config: dict[str, Any] | None = None,
96+
) -> Any:
9297
return self.paddlex_pipeline.save_vector(
9398
vector_info=vector_info,
9499
save_path=save_path,
95100
retriever_config=retriever_config,
96101
)
97102

98-
def load_vector(self, data_path: str, retriever_config: dict[str, Any] | None = None) -> Any:
103+
def load_vector(
104+
self, data_path: str, retriever_config: dict[str, Any] | None = None
105+
) -> Any:
99106
return self.paddlex_pipeline.load_vector(
100107
data_path=data_path, retriever_config=retriever_config
101108
)
@@ -233,7 +240,13 @@ def build_vector(
233240
retriever_config=retriever_config,
234241
)
235242

236-
def mllm_pred(self, input: InputType, key_list: list[str], *, mllm_chat_bot_config: dict[str, Any] | None = None) -> Any:
243+
def mllm_pred(
244+
self,
245+
input: InputType,
246+
key_list: list[str],
247+
*,
248+
mllm_chat_bot_config: dict[str, Any] | None = None,
249+
) -> Any:
237250
return self.paddlex_pipeline.mllm_pred(
238251
input,
239252
key_list,

paddleocr/_pipelines/pp_structurev3.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,9 @@ def _get_paddlex_config_overrides(self) -> dict[str, Any]:
534534
}
535535
return create_config_from_structure(STRUCTURE)
536536

537-
def _get_ocr_model_names(self, lang: str | None, ppocr_version: str | None) -> tuple[str | None, str | None]:
537+
def _get_ocr_model_names(
538+
self, lang: str | None, ppocr_version: str | None
539+
) -> tuple[str | None, str | None]:
538540
LATIN_LANGS = [
539541
"af",
540542
"az",

paddleocr/_pipelines/utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@
1717
from typing import Any
1818

1919

20-
def create_config_from_structure(structure: dict[str, Any], *, unset: Any = None, config: dict[str, Any] | None = None) -> dict[str, Any]:
20+
def create_config_from_structure(
21+
structure: dict[str, Any],
22+
*,
23+
unset: Any = None,
24+
config: dict[str, Any] | None = None,
25+
) -> dict[str, Any]:
2126
if config is None:
2227
config = {}
2328
for k, v in structure.items():

paddleocr/_utils/cli.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ def get_subcommand_args(args: argparse.Namespace) -> dict[str, Any]:
3232
return args_dict
3333

3434

35-
def add_simple_inference_args(subparser: argparse.ArgumentParser, *, input_help: str | None = None) -> None:
35+
def add_simple_inference_args(
36+
subparser: argparse.ArgumentParser, *, input_help: str | None = None
37+
) -> None:
3638
if input_help is None:
3739
input_help = "Input path or URL."
3840
subparser.add_argument(
@@ -49,7 +51,11 @@ def add_simple_inference_args(subparser: argparse.ArgumentParser, *, input_help:
4951
)
5052

5153

52-
def perform_simple_inference(wrapper_cls: type, params: dict[str, Any], predict_param_names: set[str] | None = None) -> None:
54+
def perform_simple_inference(
55+
wrapper_cls: type,
56+
params: dict[str, Any],
57+
predict_param_names: set[str] | None = None,
58+
) -> None:
5359
params = params.copy()
5460

5561
input_ = params.pop("input")

0 commit comments

Comments
 (0)