Skip to content

Commit df830bb

Browse files
formate add new pre-commit
1 parent 587e0f2 commit df830bb

File tree

261 files changed

+1207
-967
lines changed

Some content is hidden

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

261 files changed

+1207
-967
lines changed

.pre-commit-config.yaml

+28-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
1-
2-
# See https://pre-commit.com for more information
3-
# See https://pre-commit.com/hooks.html for more hooks
4-
fail_fast: true
51
repos:
6-
- repo: https://github.com/psf/black
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.5.0
4+
hooks:
5+
- id: check-json
6+
- id: end-of-file-fixer
7+
types: [file, python]
8+
- id: check-yaml
9+
- id: trailing-whitespace
10+
types: [file, python]
11+
- id: mixed-line-ending
12+
- id: check-added-large-files
13+
args: [--maxkb=4096]
14+
- repo: https://github.com/psf/black
715
rev: 23.12.1
816
hooks:
9-
- id: black
10-
- repo: https://github.com/pre-commit/pre-commit-hooks
11-
rev: v4.5.0
17+
- id: black
18+
- repo: https://github.com/pycqa/isort
19+
rev: 5.13.2
1220
hooks:
13-
- id: trailing-whitespace
14-
- id: end-of-file-fixer
15-
- id: check-yaml
16-
- id: check-added-large-files
21+
- id: isort
22+
name: isort (python)
23+
args:
24+
[
25+
"--profile",
26+
"black",
27+
"-l",
28+
"88",
29+
"--trailing-comma",
30+
"--multi-line",
31+
"3",
32+
]

Cython/compile_pyx_then_use/compile_method_1.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
33
编译Cython(不够通用)
44
5-
我们说构建扩展模块的过程分为两步:
6-
1. 将 Cython 代码翻译成 C 代码(由 cython 编译器完成,即cythonize);
5+
我们说构建扩展模块的过程分为两步:
6+
1. 将 Cython 代码翻译成 C 代码(由 cython 编译器完成,即cythonize);
77
a. cythonize 负责将 Cython 代码转成 C 代码, 这里我们可以传入单个文件, 也可以是多个文件组成的列表
88
b. 或者一个glob模式, 会匹配满足模式的所有 Cython 文件
99
2. 根据 C 代码生成扩展模块(由 distutils完成 ,即distutils.core下的setup)
@@ -14,13 +14,14 @@
1414
即可完成上述两步
1515
1616
执行命令后,在MacOS 中,我们能看到输出的文件: fib.cpython-311-darwin.so
17-
17+
1818
"""
1919

2020
import os
21-
from distutils.core import setup, Extension
21+
from distutils.core import setup
22+
2223
from Cython.Build import cythonize
2324

24-
cython_file=os.path.join(os.path.abspath("."),"fib.pyx")
25+
cython_file = os.path.join(os.path.abspath("."), "fib.pyx")
2526
# #language_level=3 表示只需要兼容 python3 (默认是 2 和 3 )
26-
setup(ext_modules=cythonize(cython_file, language_level=3))
27+
setup(ext_modules=cythonize(cython_file, language_level=3))

Cython/compile_pyx_then_use/compile_method_2.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
编译Cython的第二种方法(推荐)
44
5-
执行命令
5+
执行命令
66
python compile_method_2.py build_ext --inplace
77
即可完成上述两步
88
@@ -11,7 +11,8 @@
1111
"""
1212

1313
import os
14-
from distutils.core import setup, Extension
14+
from distutils.core import Extension, setup
15+
1516
from Cython.Build import cythonize
1617

1718
cython_file = os.path.join(os.path.abspath("."), "fib.pyx")

Cython/invoke_c/compile_invoke_c.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
33
编译Cython的第二种方法(推荐)
44
5-
执行编译命令
5+
执行编译命令
66
python compile_invoke_c.py build_ext --inplace
77
88
99
执行命令后,在MacOS 中,我们能看到输出的文件: fib.cpython-311-darwin.so
10-
10+
1111
"""
1212

13-
from distutils.core import setup,Extension
13+
from distutils.core import Extension, setup
14+
1415
from Cython.Build import cythonize
1516

1617
ext = Extension(name="wrapper_cfib", sources=["with_c_code.pyx", "cfib.c"])

acrobatics/bar_chart_race/generate_color.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import pandas as pd
2-
import bar_chart_race as bcr
31
from pprint import pprint
4-
from bar_chart_race._colormaps import colormaps
52

3+
import bar_chart_race as bcr
4+
import pandas as pd
5+
from bar_chart_race._colormaps import colormaps
66

77
df = pd.read_csv("acrobatics/bar_chart_race/covid19_tutorial.csv", index_col=["date"])
88

acrobatics/bar_chart_race/generate_dynamic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import pandas as pd
21
import bar_chart_race as bcr
32
import matplotlib.pyplot as plt
3+
import pandas as pd
44

55
# 设置字体,否则无法显示中文
66
plt.rcParams["font.sans-serif"] = ["SimHei"] # Windows

acrobatics/bar_chart_race/generate_gif.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pandas as pd
21
import bar_chart_race as bcr
2+
import pandas as pd
33

44
# 获取数据
55
df = pd.read_csv("acrobatics/bar_chart_race/covid19_tutorial.csv", index_col=["date"])

acrobatics/emoji/hello_emoji.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
print(
1010
"----------------------------Forward parsing phrase------------------------------"
1111
)
12-
emoji_grammar = emoji.emojize(f"emoji_grammar_test: 你在想 :peach: 吃")
12+
emoji_grammar = emoji.emojize("emoji_grammar_test: 你在想 :peach: 吃")
1313
print(emoji_grammar)
1414

1515
print("*" * 80)

acrobatics/prettytable/prettytable_base.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
from re import T
2-
from prettytable import PrettyTable, from_csv
3-
import prettytable
4-
1+
from prettytable import PrettyTable
52

63
print(
74
"---------------------------------base useage---------------------------------------"

acrobatics/prettytable/prettytable_read_from.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from prettytable import from_csv
22

3-
43
print(
54
"\n---------------------------------read from csv---------------------------------------\n"
65
)

acrobatics/prettytable/prettytable_style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from prettytable import PrettyTable
21
import prettytable
2+
from prettytable import PrettyTable
33

44
x = PrettyTable(["City name", "Area", "Population", "Annual Rainfall"])
55

acrobatics/pyfiglet/hello_pyfiglet.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from pyfiglet import Figlet
22

33
f = Figlet()
4-
print(f.renderText("hanser"))
4+
print(f.renderText("hanser"))
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from pyfiglet import Figlet
2-
from pyfiglet import FigletFont
1+
from pyfiglet import Figlet, FigletFont
32

43
print(FigletFont().getFonts())
54

@@ -9,7 +8,9 @@
98
f = Figlet(font="slant")
109
print(f.renderText("hanser"))
1110

12-
print("--------------------------------specify width------------------------------------")
11+
print(
12+
"--------------------------------specify width------------------------------------"
13+
)
1314

1415
f = Figlet(font="slant", width=20)
1516
print(f.renderText("hanser"))

acrobatics/pynput/keyboard/keyboard_click.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from curses import A_ALTCHARSET
21
import time
3-
from pynput.keyboard import Key, Controller
2+
3+
from pynput.keyboard import Controller, Key
44

55
keyboard: Controller = Controller()
66

acrobatics/pynput/keyboard/keyboard_listener.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
def on_press(key):
55
# 当按下esc,结束监听
66
if key == Key.esc:
7-
print(f"你按下了esc,监听结束")
7+
print("你按下了esc,监听结束")
88
return False
99
print(f"你按下了{key.char if hasattr(key, 'char') else key.name}键")
1010

acrobatics/pynput/mouse/mouse_click.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
2-
from pynput.mouse import Button, Controller
32

3+
from pynput.mouse import Button, Controller
44

55
mouse = Controller() # Objects for manipulating the mouse
66

acrobatics/pynput/mouse/mouse_listener.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from threading import Thread
21
import threading
3-
from pynput.mouse import Listener, Button
2+
3+
from pynput.mouse import Button, Listener
44

55

66
def on_move(x, y):

acrobatics/pynput/mouse/mouse_position.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
2-
from pynput.mouse import Controller
32

3+
from pynput.mouse import Controller
44

55
mouse = Controller() # Objects for manipulating the mouse
66
print(f"当前鼠标位置: {mouse.position}")

acrobatics/pynput/mouse/mouse_scroll.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import time
2-
from pynput.mouse import Controller
32

3+
from pynput.mouse import Controller
44

55
mouse = Controller() # Objects for manipulating the mouse
66
time.sleep(1)

0 commit comments

Comments
 (0)