/
test_projects_using_isort.py
147 lines (103 loc) · 4.4 KB
/
test_projects_using_isort.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
"""Tests projects that use isort to see if any differences are found between
their current imports and what isort suggest on the develop branch.
This is an important early warning signal of regressions.
NOTE: If you use isort within a public repository, please feel empowered to add your project here!
It is important to isort that as few regressions as possible are experienced by our users.
Having your project tested here is the most sure way to keep those regressions form ever happening.
"""
from pathlib import Path
from subprocess import check_call
from typing import Sequence
from isort.main import main
def git_clone(repository_url: str, directory: Path):
"""Clones the given repository into the given directory path"""
check_call(["git", "clone", "--depth", "1", repository_url, str(directory)])
def run_isort(arguments: Sequence[str]):
"""Runs isort in diff and check mode with the given arguments"""
main(["--check-only", "--diff", *arguments])
def test_django(tmpdir):
git_clone("https://github.com/django/django.git", tmpdir)
run_isort(
str(target_dir) for target_dir in (tmpdir / "django", tmpdir / "tests", tmpdir / "scripts")
)
def test_plone(tmpdir):
git_clone("https://github.com/plone/plone.app.multilingualindexes.git", tmpdir)
run_isort([str(tmpdir / "src")])
def test_pandas(tmpdir):
# Need to limit extensions as isort has just made sorting pxd the default, and pandas
# will have not picked it up yet
# TODO: Remove below line as soon as these files are sorted on the mainline pandas project
git_clone("https://github.com/pandas-dev/pandas.git", tmpdir)
limit_extensions = ("--ext", "py", "--ext", "pyi", "--ext", "pyx")
run_isort((str(tmpdir / "pandas"), "--skip", "__init__.py", *limit_extensions))
def test_fastapi(tmpdir):
git_clone("https://github.com/tiangolo/fastapi.git", tmpdir)
run_isort([str(tmpdir / "fastapi")])
def test_zulip(tmpdir):
git_clone("https://github.com/zulip/zulip.git", tmpdir)
run_isort((str(tmpdir), "--skip", "__init__.pyi"))
def test_habitat_lab(tmpdir):
git_clone("https://github.com/facebookresearch/habitat-lab.git", tmpdir)
run_isort([str(tmpdir)])
def test_tmuxp(tmpdir):
git_clone("https://github.com/tmux-python/tmuxp.git", tmpdir)
run_isort([str(tmpdir)])
def test_websockets(tmpdir):
git_clone("https://github.com/aaugustin/websockets.git", tmpdir)
run_isort((str(tmpdir), "--skip", "example", "--skip", "docs", "--skip", "compliance"))
def test_airflow(tmpdir):
git_clone("https://github.com/apache/airflow.git", tmpdir)
run_isort([str(tmpdir)])
def test_typeshed(tmpdir):
git_clone("https://github.com/python/typeshed.git", tmpdir)
run_isort(
(
str(tmpdir),
"--skip",
"tests",
"--skip",
"scripts",
"--skip",
f"{tmpdir}/third_party/2and3/yaml/__init__.pyi",
)
)
def test_pylint(tmpdir):
git_clone("https://github.com/PyCQA/pylint.git", tmpdir)
run_isort([str(tmpdir)])
def test_poetry(tmpdir):
git_clone("https://github.com/python-poetry/poetry.git", tmpdir)
run_isort((str(tmpdir), "--skip", "tests"))
def test_hypothesis(tmpdir):
git_clone("https://github.com/HypothesisWorks/hypothesis.git", tmpdir)
run_isort((str(tmpdir), "--skip", "tests"))
def test_pillow(tmpdir):
git_clone("https://github.com/python-pillow/Pillow.git", tmpdir)
run_isort((str(tmpdir), "--skip", "tests"))
def test_attrs(tmpdir):
git_clone("https://github.com/python-attrs/attrs.git", tmpdir)
run_isort(
(
str(tmpdir),
"--skip",
"tests",
"--ext",
"py",
"--skip",
"_compat.py",
)
)
def test_datadog_integrations_core(tmpdir):
git_clone("https://github.com/DataDog/integrations-core.git", tmpdir)
run_isort([str(tmpdir)])
def test_pyramid(tmpdir):
git_clone("https://github.com/Pylons/pyramid.git", tmpdir)
run_isort(
str(target_dir)
for target_dir in (tmpdir / "src" / "pyramid", tmpdir / "tests", tmpdir / "setup.py")
)
def test_products_zopetree(tmpdir):
git_clone("https://github.com/jugmac00/Products.ZopeTree.git", tmpdir)
run_isort([str(tmpdir)])
def test_dobby(tmpdir):
git_clone("https://github.com/rocketDuck/dobby.git", tmpdir)
run_isort([str(tmpdir / "tests"), str(tmpdir / "src")])