# flake8 and black disagree about
# W503 line break before binary operator
# E203 whitespace before ':'
- W503,E203
+ # E701/E704 multiple statements on one line
+ # https://black.readthedocs.io/en/latest/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
+ W503,E203,E701,E704
doctests = true
async def maybe_create_tables(db):
try:
- with (await db.cursor()) as cur:
+ with await db.cursor() as cur:
await cur.execute("SELECT COUNT(*) FROM entries LIMIT 1")
await cur.fetchone()
except psycopg2.ProgrammingError:
with open("schema.sql") as f:
schema = f.read()
- with (await db.cursor()) as cur:
+ with await db.cursor() as cur:
await cur.execute(schema)
Must be called with ``await self.execute(...)``
"""
- with (await self.application.db.cursor()) as cur:
+ with await self.application.db.cursor() as cur:
await cur.execute(stmt, args)
async def query(self, stmt, *args):
for row in await self.query(...)
"""
- with (await self.application.db.cursor()) as cur:
+ with await self.application.db.cursor() as cur:
await cur.execute(stmt, args)
return [self.row_to_obj(row, cur) for row in await cur.fetchall()]
- Run this file with `python main.py --config_file=main.cfg`
- Visit "http://localhost:8888" in your browser.
"""
+
import asyncio
import json
import tornado
# via sphinx
babel==2.11.0
# via sphinx
-black==22.12.0
+black==24.4.2
# via -r requirements.in
build==0.10.0
# via pip-tools
# mypy
packaging==23.1
# via
+ # black
# build
# pyproject-api
# sphinx
The ``callback`` argument was removed.
"""
+
# Fully type-checking decorators is tricky, and this one is
# discouraged anyway so it doesn't have all the generic magic.
def run_on_executor_decorator(fn: Callable) -> Callable[..., Future]:
via ``singledispatch``.
"""
+
import asyncio
import builtins
import collections
@overload
def coroutine(
func: Callable[..., "Generator[Any, Any, _T]"]
-) -> Callable[..., "Future[_T]"]:
- ...
+) -> Callable[..., "Future[_T]"]: ...
@overload
-def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]:
- ...
+def coroutine(func: Callable[..., _T]) -> Callable[..., "Future[_T]"]: ...
def coroutine(
self.request.method == "POST"
and "Content-Type" not in self.request.headers
):
- self.request.headers[
- "Content-Type"
- ] = "application/x-www-form-urlencoded"
+ self.request.headers["Content-Type"] = (
+ "application/x-www-form-urlencoded"
+ )
if self.request.decompress_response:
self.request.headers["Accept-Encoding"] = "gzip"
req_path = (self.parsed.path or "/") + (
This only works in python 2.7+.
"""
+
from tornado.test.runtests import all, main
# tornado.testing.main autodiscovery relies on 'all' being present in
(
"www.external-link.com and www.internal-link.com/blogs extra",
{
- "extra_params": lambda href: 'class="internal"'
- if href.startswith("http://www.internal-link.com")
- else 'rel="nofollow" class="external"'
+ "extra_params": lambda href: (
+ 'class="internal"'
+ if href.startswith("http://www.internal-link.com")
+ else 'rel="nofollow" class="external"'
+ )
},
'<a href="http://www.external-link.com" rel="nofollow" class="external">www.external-link.com</a>' # noqa: E501
' and <a href="http://www.internal-link.com/blogs" class="internal">www.internal-link.com/blogs</a> extra', # noqa: E501
the object should be closed (by IOLoop.close(all_fds=True),
not just the fd.
"""
+
# Use a socket since they are supported by IOLoop on all platforms.
# Unfortunately, sockets don't support the .closed attribute for
# inspecting their close status, so we must use a wrapper.
# from the server).
# TODO: set server parameters for deflate extension
# if requested in self.compression_options.
- request.headers[
- "Sec-WebSocket-Extensions"
- ] = "permessage-deflate; client_max_window_bits"
+ request.headers["Sec-WebSocket-Extensions"] = (
+ "permessage-deflate; client_max_window_bits"
+ )
# Websocket connection is currently unable to follow redirects
request.follow_redirects = False