pre-commit autoupdate (#538)
* pre-commit autoupdate
* Add pyproject.toml; --keep-mock in pyupgrade
Steven Loria authored 3 years ago
GitHub committed 3 years ago
0 | 0 |
repos:
|
1 | 1 |
- repo: https://github.com/asottile/pyupgrade
|
2 | |
rev: v1.26.0
|
|
2 |
rev: v2.7.2
|
3 | 3 |
hooks:
|
4 | 4 |
- id: pyupgrade
|
5 | |
args: ["--py3-plus"]
|
|
5 |
args: ["--py3-plus", "--keep-mock"]
|
6 | 6 |
- repo: https://github.com/psf/black
|
7 | |
rev: 19.10b0
|
|
7 |
rev: 20.8b1
|
8 | 8 |
hooks:
|
9 | 9 |
- id: black
|
10 | |
args: ["--target-version", "py35"]
|
11 | |
language_version: python3
|
12 | 10 |
- repo: https://gitlab.com/pycqa/flake8
|
13 | |
rev: 3.7.9
|
|
11 |
rev: 3.8.3
|
14 | 12 |
hooks:
|
15 | 13 |
- id: flake8
|
16 | 14 |
additional_dependencies: [flake8-bugbear==20.1.0]
|
17 | 15 |
- repo: https://github.com/asottile/blacken-docs
|
18 | |
rev: v1.5.0-1
|
|
16 |
rev: v1.8.0
|
19 | 17 |
hooks:
|
20 | 18 |
- id: blacken-docs
|
21 | |
additional_dependencies: [black==19.10b0]
|
|
19 |
additional_dependencies: [black==20.8b1]
|
22 | 20 |
args: ["--target-version", "py35"]
|
23 | 21 |
- repo: https://github.com/pre-commit/mirrors-mypy
|
24 | |
rev: v0.761
|
|
22 |
rev: v0.782
|
25 | 23 |
hooks:
|
26 | 24 |
- id: mypy
|
27 | 25 |
language_version: python3
|
442 | 442 |
|
443 | 443 |
@route("/users/<_id:int>", method="GET", apply=use_args(user_args))
|
444 | 444 |
def users(args, _id):
|
445 | |
"""A welcome page.
|
446 | |
"""
|
|
445 |
"""A welcome page."""
|
447 | 446 |
return {"message": "Welcome, {}!".format(args["name"]), "_id": _id}
|
24 | 24 |
|
25 | 25 |
@use_args(hello_args)
|
26 | 26 |
async def index(request, args):
|
27 | |
"""A welcome page.
|
28 | |
"""
|
|
27 |
"""A welcome page."""
|
29 | 28 |
return json_response({"message": "Welcome, {}!".format(args["name"])})
|
30 | 29 |
|
31 | 30 |
|
95 | 95 |
|
96 | 96 |
|
97 | 97 |
@route("/", methods=["GET"])
|
98 | |
def index(name: fields.Str(missing="Friend")):
|
|
98 |
def index(name: fields.Str(missing="Friend")): # noqa: F821
|
99 | 99 |
return {"message": "Hello, {}!".format(name)}
|
100 | 100 |
|
101 | 101 |
|
23 | 23 |
|
24 | 24 |
@route("/", method="GET", apply=use_args(hello_args))
|
25 | 25 |
def index(args):
|
26 | |
"""A welcome page.
|
27 | |
"""
|
|
26 |
"""A welcome page."""
|
28 | 27 |
return {"message": "Welcome, {}!".format(args["name"])}
|
29 | 28 |
|
30 | 29 |
|
25 | 25 |
@app.route("/", methods=["GET"])
|
26 | 26 |
@use_args(hello_args)
|
27 | 27 |
def index(args):
|
28 | |
"""A welcome page.
|
29 | |
"""
|
|
28 |
"""A welcome page."""
|
30 | 29 |
return jsonify({"message": "Welcome, {}!".format(args["name"])})
|
31 | 30 |
|
32 | 31 |
|
28 | 28 |
@view_config(route_name="hello", request_method="GET", renderer="json")
|
29 | 29 |
@use_args(hello_args)
|
30 | 30 |
def index(request, args):
|
31 | |
"""A welcome page.
|
32 | |
"""
|
|
31 |
"""A welcome page."""
|
33 | 32 |
return {"message": "Welcome, {}!".format(args["name"])}
|
34 | 33 |
|
35 | 34 |
|
60 | 60 |
|
61 | 61 |
def use_schema(schema_cls, list_view=False, locations=None):
|
62 | 62 |
"""View decorator for using a marshmallow schema to
|
63 | |
(1) parse a request's input and
|
64 | |
(2) serializing the view's output to a JSON response.
|
|
63 |
(1) parse a request's input and
|
|
64 |
(2) serializing the view's output to a JSON response.
|
65 | 65 |
"""
|
66 | 66 |
|
67 | 67 |
def decorator(func):
|
|
0 |
[tool.black]
|
|
1 |
line-length = 88
|
|
2 |
target-version = ['py35', 'py36', 'py37', 'py38']
|
37 | 37 |
Raises RuntimeError if not found.
|
38 | 38 |
"""
|
39 | 39 |
version = ""
|
40 | |
with open(fname, "r") as fp:
|
|
40 |
with open(fname) as fp:
|
41 | 41 |
reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
|
42 | 42 |
for line in fp:
|
43 | 43 |
m = reg.match(line)
|
516 | 516 |
return missing
|
517 | 517 |
|
518 | 518 |
def load_headers(self, req, schema):
|
519 | |
"""Load the headers or return `missing` if no value can be found.
|
520 | |
"""
|
|
519 |
"""Load the headers or return `missing` if no value can be found."""
|
521 | 520 |
return missing
|
522 | 521 |
|
523 | 522 |
def load_cookies(self, req, schema):
|
53 | 53 |
|
54 | 54 |
|
55 | 55 |
class HTTPError(falcon.HTTPError):
|
56 | |
"""HTTPError that stores a dictionary of validation error messages.
|
57 | |
"""
|
|
56 |
"""HTTPError that stores a dictionary of validation error messages."""
|
58 | 57 |
|
59 | 58 |
def __init__(self, status, errors, *args, **kwargs):
|
60 | 59 |
self.errors = errors
|
47 | 47 |
def test_body_parsing_works_with_simulate(self):
|
48 | 48 |
app = self.create_app()
|
49 | 49 |
client = falcon.testing.TestClient(app)
|
50 | |
res = client.simulate_post("/echo_json", json={"name": "Fred"},)
|
|
50 |
res = client.simulate_post(
|
|
51 |
"/echo_json",
|
|
52 |
json={"name": "Fred"},
|
|
53 |
)
|
51 | 54 |
assert res.json == {"name": "Fred"}
|
14 | 14 |
commands = pytest {posargs}
|
15 | 15 |
|
16 | 16 |
[testenv:lint]
|
17 | |
deps = pre-commit~=1.20
|
|
17 |
deps = pre-commit~=2.4
|
18 | 18 |
skip_install = true
|
19 | 19 |
commands = pre-commit run --all-files
|
20 | 20 |
|