Skip to content

Commit

Permalink
Merge branch 'master' into remove_deprecated_in_http_error
Browse files Browse the repository at this point in the history
  • Loading branch information
vytas7 authored May 21, 2022
2 parents 96a554b + a9ea4a9 commit 7d2db96
Show file tree
Hide file tree
Showing 21 changed files with 31 additions and 72 deletions.
40 changes: 0 additions & 40 deletions .github/workflows/tests-3.5.2.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
- "ubuntu-20.04"
toxenv:
- "pep8"
- "black"
- "blue"
- "pep8-examples"
- "pep8-docstrings"
- "mypy"
Expand Down
10 changes: 6 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ Please note that all contributors and maintainers of this project are subject to

### Pull Requests

Before submitting a pull request, please ensure you have added or updated tests as appropriate, and that all existing tests still pass with your changes. Please also ensure that your coding style follows PEP 8 and the ``black`` formatting style.
Before submitting a pull request, please ensure you have added or updated tests as appropriate,
and that all existing tests still pass with your changes.
Please also ensure that your coding style follows PEP 8 and the ``blue`` formatting style.

In order to reformat your code with ``black``, simply issue:
In order to reformat your code with ``blue``, simply issue:

```bash
$ pip install -U black
$ black .
$ pip install -U blue
$ blue .
```

You can check all this by running ``tox`` from within the Falcon project directory. Your environment must be based on CPython 3.8 or 3.10:
Expand Down
8 changes: 4 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
>
</a>

|Build Status| |Docs| |codecov.io|
|Build Status| |Docs| |codecov.io| |Blue|

The Falcon Web Framework
========================
Expand Down Expand Up @@ -1045,10 +1045,10 @@ limitations under the License.
.. |Docs| image:: https://readthedocs.org/projects/falcon/badge/?version=stable
:target: https://falcon.readthedocs.io/en/stable/?badge=stable
:alt: Falcon web framework docs
.. |Runner| image:: https://a248.e.akamai.net/assets.github.com/images/icons/emoji/runner.png
:width: 20
:height: 20
.. |Build Status| image:: https://github.com/falconry/falcon/workflows/Run%20tests/badge.svg
:target: https://github.com/falconry/falcon/actions?query=workflow%3A%22Run+tests%22
.. |codecov.io| image:: https://codecov.io/gh/falconry/falcon/branch/master/graphs/badge.svg
:target: http://codecov.io/gh/falconry/falcon
.. |Blue| image:: https://img.shields.io/badge/code%20style-blue-blue.svg
:target: https://blue.readthedocs.io/
:alt: code style: blue
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

# General information about the project.
project = 'Falcon'
copyright = "{year} Falcon Contributors".format(year=datetime.utcnow().year)
copyright = '{year} Falcon Contributors'.format(year=datetime.utcnow().year)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
1 change: 0 additions & 1 deletion docs/ext/rfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
formatted like this::
RFC 7231; Section 6.5.3
"""

import re
Expand Down
1 change: 0 additions & 1 deletion falcon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import falcon
app = falcon.App()
"""

import logging as _logging
Expand Down
1 change: 0 additions & 1 deletion falcon/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def on_get(self, req, resp):
)
# -- snip --
"""

from datetime import datetime
Expand Down
4 changes: 2 additions & 2 deletions falcon/response_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def format_content_disposition(value, disposition_type='attachment'):
def format_etag_header(value):
"""Format an ETag header, wrap it with " " in case of need."""

if value[-1] != '\"':
value = '\"' + value + '\"'
if value[-1] != '"':
value = '"' + value + '"'

return value

Expand Down
7 changes: 3 additions & 4 deletions falcon/testing/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
from falcon import testing
wsgi_environ = testing.create_environ()
"""

import asyncio
Expand Down Expand Up @@ -303,8 +302,8 @@ class ASGIResponseEventCollector:
]
)

_HEADER_NAME_RE = re.compile(br'^[a-zA-Z][a-zA-Z0-9\-_]*$')
_BAD_HEADER_VALUE_RE = re.compile(br'[\000-\037]')
_HEADER_NAME_RE = re.compile(rb'^[a-zA-Z][a-zA-Z0-9\-_]*$')
_BAD_HEADER_VALUE_RE = re.compile(rb'[\000-\037]')

def __init__(self):
self.events = []
Expand Down Expand Up @@ -802,7 +801,7 @@ def get_encoding_from_headers(headers):
content_type, params = cgi.parse_header(content_type)

if 'charset' in params:
return params['charset'].strip("'\"")
return params['charset'].strip('\'"')

# NOTE(kgriffs): Added checks for text/event-stream and application/json
if content_type in ('text/event-stream', 'application/json'):
Expand Down
1 change: 0 additions & 1 deletion falcon/testing/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from falcon import testing
resource = testing.SimpleTestResource()
"""

from json import dumps as json_dumps
Expand Down
1 change: 0 additions & 1 deletion falcon/util/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
some_uri = '...'
decoded_uri = uri.decode(some_uri)
"""

from http import cookies as http_cookies
Expand Down
1 change: 0 additions & 1 deletion falcon/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import falcon
now = falcon.http_now()
"""

import datetime
Expand Down
1 change: 0 additions & 1 deletion falcon/util/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import falcon
things = falcon.CaseInsensitiveDict()
"""

from collections.abc import Mapping
Expand Down
1 change: 0 additions & 1 deletion falcon/util/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import falcon
tz = falcon.TimezoneGMT()
"""

import datetime
Expand Down
1 change: 0 additions & 1 deletion falcon/util/uri.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
from falcon import uri
name, port = uri.parse_host('example.org:8080')
"""

from falcon.constants import PYPY
Expand Down
7 changes: 7 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@
showcontent = true

[tool.black]
# this is kept to avoid reformatting all the code if one were to
# inadvertently run black on the probject
target-version = ["py35"]
skip-string-normalization = true
line-length = 88
extend-exclude = "falcon/vendor"

[tool.blue]
target-version = ["py35"]
line-length = 88
extend-exclude = "falcon/vendor"
2 changes: 1 addition & 1 deletion tests/test_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ def __init__(self, with_double_quotes):
def on_get(self, req, resp):
etag = 'fa0d1a60ef6616bb28038515c8ea4cb2'
if self.with_double_quotes:
etag = '\"' + etag + '\"'
etag = '"' + etag + '"'

resp.etag = etag
assert resp.etag == '"fa0d1a60ef6616bb28038515c8ea4cb2"'
Expand Down
2 changes: 1 addition & 1 deletion tests/test_request_access_route.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def test_rfc_forwarded(asgi):
'for="[2001:db8:cafe::17]:555",'
'for=x,'
'for="unknown", by=_hidden,for="\\"\\\\",'
'for="_don\\\"t_\\try_this\\\\at_home_\\42",'
'for="_don\\"t_\\try_this\\\\at_home_\\42",'
'for="198\\.51\\.100\\.17\\:1236";'
'proto=https;host=example.com'
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_response_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ async def __anext__(self):
class CodeResource:
def on_get(self, req, resp):
resp.content_type = 'text/x-malbolge'
resp.media = '\'&%$#"!76543210/43,P0).\'&%I6'
resp.media = "'&%$#\"!76543210/43,P0).'&%I6"
resp.status = falcon.HTTP_725


Expand Down
8 changes: 4 additions & 4 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# --------------------------------------------------------------------

envlist = cleanup,
black,
blue,
pep8,
mypy,
mintest,
Expand Down Expand Up @@ -264,9 +264,9 @@ deps = flake8>=3.7.0
flake8-import-order
commands = flake8 []

[testenv:black]
deps = black>=22.1.0
commands = black --check . []
[testenv:blue]
deps = blue>=0.9.0
commands = blue --check . []

[testenv:pep8-docstrings]
deps = flake8
Expand Down

0 comments on commit 7d2db96

Please sign in to comment.