Skip to content

Commit 6f71621

Browse files
authored
[misc] lint compat python3.12 (#8073)
1 parent 88b6f02 commit 6f71621

File tree

406 files changed

+1004
-1436
lines changed

Some content is hidden

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

406 files changed

+1004
-1436
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
11
repos:
22
- repo: https://github.com/pycqa/flake8.git
3-
rev: 4.0.0
3+
rev: 7.3.0
44
hooks:
55
- id: flake8
6-
exclude: |
7-
(?x)^(
8-
thirdparty/|
9-
examples/|
10-
tests/run.py
11-
)$
126
- repo: https://github.com/PyCQA/isort.git
13-
rev: 4.3.21
7+
rev: 8.0.0
148
hooks:
159
- id: isort
16-
exclude: |
17-
(?x)^(
18-
examples/|
19-
tests/run.py|
20-
swift/cli/sft.py
21-
)$
2210
- repo: https://github.com/pre-commit/mirrors-yapf.git
23-
rev: v0.30.0
11+
rev: v0.32.0
2412
hooks:
2513
- id: yapf
26-
exclude: |
27-
(?x)^(
28-
thirdparty/|
29-
examples/|
30-
tests/run.py
31-
)$
3214
- repo: https://github.com/pre-commit/pre-commit-hooks.git
33-
rev: v4.5.0
15+
rev: v6.0.0
3416
hooks:
3517
- id: trailing-whitespace
36-
exclude: thirdparty/|tests/run.py
3718
- id: check-yaml
38-
exclude: thirdparty/|tests/run.py
3919
- id: end-of-file-fixer
40-
exclude: thirdparty/|tests/run.py
4120
- id: requirements-txt-fixer
42-
exclude: thirdparty/|tests/run.py
4321
- id: double-quote-string-fixer
44-
exclude: thirdparty/|tests/run.py
4522
- id: check-merge-conflict
46-
exclude: thirdparty/|tests/run.py
47-
- id: fix-encoding-pragma
48-
exclude: thirdparty/|tests/run.py
49-
args: ["--remove"]
5023
- id: mixed-line-ending
51-
exclude: thirdparty/|tests/run.py
5224
args: ["--fix=lf"]

.pre-commit-config_local.yaml

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,24 @@
11
repos:
22
- repo: /home/admin/pre-commit/flake8
3-
rev: 4.0.0
3+
rev: 7.3.0
44
hooks:
55
- id: flake8
6-
exclude: |
7-
(?x)^(
8-
thirdparty/|
9-
examples/|
10-
tests/run.py
11-
)$
126
- repo: /home/admin/pre-commit/isort
13-
rev: 4.3.21
7+
rev: 8.0.0
148
hooks:
159
- id: isort
16-
exclude: |
17-
(?x)^(
18-
examples/|
19-
tests/run.py|
20-
swift/cli/sft.py
21-
)$
2210
- repo: /home/admin/pre-commit/mirrors-yapf
23-
rev: v0.30.0
11+
rev: v0.32.0
2412
hooks:
2513
- id: yapf
26-
exclude: |
27-
(?x)^(
28-
thirdparty/|
29-
examples/|
30-
tests/run.py
31-
)$
3214
- repo: /home/admin/pre-commit/pre-commit-hooks
33-
rev: v4.5.0
15+
rev: v6.0.0
3416
hooks:
3517
- id: trailing-whitespace
36-
exclude: thirdparty/|tests/run.py
3718
- id: check-yaml
38-
exclude: thirdparty/|tests/run.py
3919
- id: end-of-file-fixer
40-
exclude: thirdparty/
4120
- id: requirements-txt-fixer
42-
exclude: thirdparty/|tests/run.py
4321
- id: double-quote-string-fixer
44-
exclude: thirdparty/|tests/run.py
4522
- id: check-merge-conflict
46-
exclude: thirdparty/|tests/run.py
47-
- id: fix-encoding-pragma
48-
exclude: thirdparty/|tests/run.py
49-
args: ["--remove"]
5023
- id: mixed-line-ending
51-
exclude: thirdparty/|tests/run.py
5224
args: ["--fix=lf"]

examples/app/base_url/demo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
55

66
if __name__ == '__main__':
7-
from swift import AppArguments, app_main, DeployArguments, run_deploy
7+
from swift import AppArguments, DeployArguments, app_main, run_deploy
8+
89
# Here's a runnable demo provided.
910
# In a real scenario, you can simply remove the deployed context.
1011
with run_deploy(

examples/custom/my_qwen2_5_omni/my_register.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
from functools import partial
2-
from typing import Any, Dict, List, Literal, Optional
3-
41
import torch
2+
from functools import partial
53
from transformers import PretrainedConfig, PreTrainedModel
64
from transformers.integrations import is_deepspeed_zero3_enabled
5+
from typing import Any, Dict, List, Literal, Optional
76

87
from swift.model import (Model, ModelGroup, ModelLoader, ModelMeta, MultiModelKeys, get_model_processor, register_model,
98
register_model_arch)
@@ -44,8 +43,8 @@ def get_config(self, model_dir: str) -> PretrainedConfig:
4443
return config
4544

4645
def get_processor(self, model_dir: str, config: PretrainedConfig) -> Processor:
47-
from transformers import Qwen2_5OmniProcessor
4846
from qwen_omni_utils import vision_process
47+
from transformers import Qwen2_5OmniProcessor
4948
processor = Qwen2_5OmniProcessor.from_pretrained(model_dir, trust_remote_code=True)
5049
# Control constants in qwen_omni_utils library via environment variables,
5150
# e.g., `MAX_PIXELS`, etc.

examples/custom/my_qwen2_5_omni/test_register.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import os
2-
import sys
3-
42
import requests
3+
import sys
54
from modelscope import snapshot_download
65
from qwen_omni_utils import process_mm_info
76
from transformers import Qwen2_5OmniForConditionalGeneration, Qwen2_5OmniProcessor
@@ -80,6 +79,7 @@ def test_my_qwen2_5_omni():
8079

8180
if __name__ == '__main__':
8281
import my_register
82+
8383
# Enable debug mode, will print input_ids and generate_ids from `TransformersEngine.infer`
8484
os.environ['SWIFT_DEBUG'] = '1'
8585
input_ids_hf, response_hf = infer_hf()

examples/deploy/agent/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (c) ModelScope Contributors. All rights reserved.
22
import os
3-
43
from openai import OpenAI
54

65
os.environ['CUDA_VISIBLE_DEVICES'] = '0'

examples/deploy/client/llm/base/openai_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (c) ModelScope Contributors. All rights reserved.
22
import os
3-
43
from openai import OpenAI
54

65
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
@@ -32,7 +31,8 @@ def run_client(host: str = '127.0.0.1', port: int = 8000):
3231

3332

3433
if __name__ == '__main__':
35-
from swift import run_deploy, DeployArguments
34+
from swift import DeployArguments, run_deploy
35+
3636
# NOTE: In a real deployment scenario, please comment out the context of run_deploy.
3737
with run_deploy(
3838
DeployArguments(

examples/deploy/client/llm/base/swift_client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ def run_client(host: str = '127.0.0.1', port: int = 8000):
2424

2525

2626
if __name__ == '__main__':
27-
from swift import run_deploy, DeployArguments, InferEngine, InferRequest, InferClient, RequestConfig
27+
from swift import DeployArguments, InferClient, InferEngine, InferRequest, RequestConfig, run_deploy
28+
2829
# NOTE: In a real deployment scenario, please comment out the context of run_deploy.
2930
with run_deploy(
3031
DeployArguments(

examples/deploy/client/llm/chat/openai_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Copyright (c) ModelScope Contributors. All rights reserved.
22
import os
3-
43
from openai import OpenAI
54

65
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
@@ -43,6 +42,6 @@ def run_client(host: str = '127.0.0.1', port: int = 8000):
4342

4443

4544
if __name__ == '__main__':
46-
from swift import run_deploy, DeployArguments
45+
from swift import DeployArguments, run_deploy
4746
with run_deploy(DeployArguments(model='Qwen/Qwen2.5-1.5B-Instruct', verbose=False, log_interval=-1)) as port:
4847
run_client(port=port)

examples/deploy/client/llm/chat/swift_client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ def run_client(host: str = '127.0.0.1', port: int = 8000):
5050

5151

5252
if __name__ == '__main__':
53-
from swift import (InferEngine, InferRequest, InferClient, RequestConfig, load_dataset, run_deploy, DeployArguments,
54-
InferStats)
53+
from swift import (DeployArguments, InferClient, InferEngine, InferRequest, InferStats, RequestConfig, load_dataset,
54+
run_deploy)
55+
5556
# NOTE: In a real deployment scenario, please comment out the context of run_deploy.
5657
with run_deploy(
5758
DeployArguments(model='Qwen/Qwen2.5-1.5B-Instruct', verbose=False, log_interval=-1,

0 commit comments

Comments
 (0)