Codebase list python-webargs / 813eea5
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
14 changed file(s) with 26 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
00 repos:
11 - repo: https://github.com/asottile/pyupgrade
2 rev: v1.26.0
2 rev: v2.7.2
33 hooks:
44 - id: pyupgrade
5 args: ["--py3-plus"]
5 args: ["--py3-plus", "--keep-mock"]
66 - repo: https://github.com/psf/black
7 rev: 19.10b0
7 rev: 20.8b1
88 hooks:
99 - id: black
10 args: ["--target-version", "py35"]
11 language_version: python3
1210 - repo: https://gitlab.com/pycqa/flake8
13 rev: 3.7.9
11 rev: 3.8.3
1412 hooks:
1513 - id: flake8
1614 additional_dependencies: [flake8-bugbear==20.1.0]
1715 - repo: https://github.com/asottile/blacken-docs
18 rev: v1.5.0-1
16 rev: v1.8.0
1917 hooks:
2018 - id: blacken-docs
21 additional_dependencies: [black==19.10b0]
19 additional_dependencies: [black==20.8b1]
2220 args: ["--target-version", "py35"]
2321 - repo: https://github.com/pre-commit/mirrors-mypy
24 rev: v0.761
22 rev: v0.782
2523 hooks:
2624 - id: mypy
2725 language_version: python3
442442
443443 @route("/users/<_id:int>", method="GET", apply=use_args(user_args))
444444 def users(args, _id):
445 """A welcome page.
446 """
445 """A welcome page."""
447446 return {"message": "Welcome, {}!".format(args["name"]), "_id": _id}
2424
2525 @use_args(hello_args)
2626 async def index(request, args):
27 """A welcome page.
28 """
27 """A welcome page."""
2928 return json_response({"message": "Welcome, {}!".format(args["name"])})
3029
3130
9595
9696
9797 @route("/", methods=["GET"])
98 def index(name: fields.Str(missing="Friend")):
98 def index(name: fields.Str(missing="Friend")): # noqa: F821
9999 return {"message": "Hello, {}!".format(name)}
100100
101101
2323
2424 @route("/", method="GET", apply=use_args(hello_args))
2525 def index(args):
26 """A welcome page.
27 """
26 """A welcome page."""
2827 return {"message": "Welcome, {}!".format(args["name"])}
2928
3029
2525 @app.route("/", methods=["GET"])
2626 @use_args(hello_args)
2727 def index(args):
28 """A welcome page.
29 """
28 """A welcome page."""
3029 return jsonify({"message": "Welcome, {}!".format(args["name"])})
3130
3231
2828 @view_config(route_name="hello", request_method="GET", renderer="json")
2929 @use_args(hello_args)
3030 def index(request, args):
31 """A welcome page.
32 """
31 """A welcome page."""
3332 return {"message": "Welcome, {}!".format(args["name"])}
3433
3534
6060
6161 def use_schema(schema_cls, list_view=False, locations=None):
6262 """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.
6565 """
6666
6767 def decorator(func):
0 [tool.black]
1 line-length = 88
2 target-version = ['py35', 'py36', 'py37', 'py38']
3737 Raises RuntimeError if not found.
3838 """
3939 version = ""
40 with open(fname, "r") as fp:
40 with open(fname) as fp:
4141 reg = re.compile(r'__version__ = [\'"]([^\'"]*)[\'"]')
4242 for line in fp:
4343 m = reg.match(line)
516516 return missing
517517
518518 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."""
521520 return missing
522521
523522 def load_cookies(self, req, schema):
5353
5454
5555 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."""
5857
5958 def __init__(self, status, errors, *args, **kwargs):
6059 self.errors = errors
4747 def test_body_parsing_works_with_simulate(self):
4848 app = self.create_app()
4949 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 )
5154 assert res.json == {"name": "Fred"}
1414 commands = pytest {posargs}
1515
1616 [testenv:lint]
17 deps = pre-commit~=1.20
17 deps = pre-commit~=2.4
1818 skip_install = true
1919 commands = pre-commit run --all-files
2020