Skip to content

Commit b41c96e

Browse files
committed
add style checks
1 parent 6247e01 commit b41c96e

20 files changed

+590
-491
lines changed

.editorconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 4
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
end_of_line = lf
9+
charset = utf-8
10+
max_line_length = 88
11+
12+
[*.{yml,yaml,json,js,css,html}]
13+
indent_size = 2

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/asottile/reorder_python_imports
3+
rev: v1.3.1
4+
hooks:
5+
- id: reorder-python-imports
6+
args: ["--application-directories", "src"]
7+
- repo: https://github.com/ambv/black
8+
rev: 18.9b0
9+
hooks:
10+
- id: black
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v2.0.0
13+
hooks:
14+
- id: check-byte-order-marker
15+
- id: trailing-whitespace
16+
- id: end-of-file-fixer
17+
- id: flake8
18+
additional_dependencies: [flake8-bugbear]

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ matrix:
1515
- dist: xenial
1616
sudo: required
1717
python: "3.7"
18-
- env: TOXENV=docs-html
18+
- env: TOXENV=stylecheck,docs-html
1919
- stage: wheel
2020
sudo: required
2121
services:

bench/bench_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def run():
5-
escape('<strong>Hello World!</strong>')
5+
escape("<strong>Hello World!</strong>")

bench/bench_largestring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
def run():
5-
string = '<strong>Hello World!</strong>' * 1000
5+
string = "<strong>Hello World!</strong>" * 1000
66
escape(string)

bench/bench_long_empty_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
def run():
5-
string = 'Hello World!' * 1000
5+
string = "Hello World!" * 1000
66
escape(string)

bench/bench_long_suffix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33

44
def run():
5-
string = '<strong>Hello World!</strong>' + 'x' * 100000
5+
string = "<strong>Hello World!</strong>" + "x" * 100000
66
escape(string)

bench/bench_short_empty_string.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33

44
def run():
5-
escape('Hello World!')
5+
escape("Hello World!")

bench/runbench.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
Runs the benchmarks
44
"""
55
from __future__ import print_function
6-
import sys
6+
77
import os
88
import re
9+
import sys
910
from subprocess import Popen
1011

11-
_filename_re = re.compile(r'^bench_(.*?)\.py$')
12+
_filename_re = re.compile(r"^bench_(.*?)\.py$")
1213
bench_directory = os.path.abspath(os.path.dirname(__file__))
1314

1415

@@ -18,27 +19,27 @@ def list_benchmarks():
1819
match = _filename_re.match(name)
1920
if match is not None:
2021
result.append(match.group(1))
21-
result.sort(key=lambda x: (x.startswith('logging_'), x.lower()))
22+
result.sort(key=lambda x: (x.startswith("logging_"), x.lower()))
2223
return result
2324

2425

2526
def run_bench(name):
26-
sys.stdout.write('%-32s' % name)
27+
sys.stdout.write("%-32s" % name)
2728
sys.stdout.flush()
28-
Popen([sys.executable, '-mtimeit', '-s',
29-
'from bench_%s import run' % name,
30-
'run()']).wait()
29+
Popen(
30+
[sys.executable, "-mtimeit", "-s", "from bench_%s import run" % name, "run()"]
31+
).wait()
3132

3233

3334
def main():
34-
print('=' * 80)
35-
print('Running benchmark for MarkupSafe')
36-
print('-' * 80)
35+
print("=" * 80)
36+
print("Running benchmark for MarkupSafe")
37+
print("-" * 80)
3738
os.chdir(bench_directory)
3839
for bench in list_benchmarks():
3940
run_bench(bench)
40-
print('-' * 80)
41+
print("-" * 80)
4142

4243

43-
if __name__ == '__main__':
44+
if __name__ == "__main__":
4445
main()

setup.cfg

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,19 @@ source =
1414
src/markupsafe
1515
.tox/*/lib/python*/site-packages/markupsafe
1616
.tox/*/site-packages/markupsafe
17+
18+
[flake8]
19+
# B = bugbear
20+
# E = pycodestyle errors
21+
# F = flake8 pyflakes
22+
# W = pycodestyle warnings
23+
# B9 = bugbear opinions
24+
select = B, E, F, W, B9
25+
# E203 = slice notation whitespace, invalid
26+
# E501 = line length, handled by bugbear B950
27+
# W503 = bin op line break, invalid
28+
ignore = E203, E501, W503
29+
# up to 88 allowed by bugbear B950
30+
max-line-length = 80
31+
# _compat names and imports will always look bad, ignore warnings
32+
exclude = src/markupsafe/_compat.py

0 commit comments

Comments
 (0)