Skip to content

Commit

Permalink
chore: replace flake8 with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
CaselIT committed Jul 11, 2024
1 parent 89ccb98 commit f3c0019
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 43 deletions.
2 changes: 0 additions & 2 deletions examples/asgilook/asgilook/cache.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import msgpack
import redis.asyncio as redis


class RedisCache:
PREFIX = 'asgilook:'
Expand Down
5 changes: 2 additions & 3 deletions falcon/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@


class App:
"""This class is the main entry point into a Falcon-based WSGI app.
"""The main entry point into a Falcon-based WSGI app.
Each App instance provides a callable
`WSGI <https://www.python.org/dev/peps/pep-3333/>`_ interface
Expand Down Expand Up @@ -1152,8 +1152,7 @@ def _update_sink_and_static_routes(self):
# TODO(myusko): This class is a compatibility alias, and should be removed
# in the next major release (4.0).
class API(App):
"""
This class is a compatibility alias of :class:`falcon.App`.
"""Compatibility alias of :class:`falcon.App`.
``API`` was renamed to :class:`App <falcon.App>` in Falcon 3.0 in order to
reflect the breadth of applications that :class:`App <falcon.App>`, and its
Expand Down
2 changes: 1 addition & 1 deletion falcon/asgi/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@


class App(falcon.app.App):
"""This class is the main entry point into a Falcon-based ASGI app.
"""The main entry point into a Falcon-based ASGI app.
Each App instance provides a callable
`ASGI <https://asgi.readthedocs.io/en/latest/>`_ interface
Expand Down
8 changes: 4 additions & 4 deletions falcon/asgi/ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,13 +635,13 @@ async def receive(self):
# NOTE(kgriffs): Wait for a message if none are available. This pattern
# was borrowed from the websockets.protocol module.
while not self._messages:
# -------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# NOTE(kgriffs): The pattern below was borrowed from the websockets.protocol
# module under the BSD 3-Clause "New" or "Revised" License.
#
# Ref: https://github.com/aaugustin/websockets/blob/master/src/websockets/protocol.py # noqa E501
#
# -------------------------------------------------------------------------------------
# --------------------------------------------------------------------------

# PERF(kgriffs): Using a bare future like this seems to be
# slightly more efficient vs. something like asyncio.Event
Expand Down Expand Up @@ -683,13 +683,13 @@ async def _pump(self):
'code', WSCloseCode.NORMAL
)

# -------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
# NOTE(kgriffs): The pattern below was borrowed from the websockets.protocol
# module under the BSD 3-Clause "New" or "Revised" License.
#
# Ref: https://github.com/aaugustin/websockets/blob/master/src/websockets/protocol.py # noqa E501
#
# -------------------------------------------------------------------------------------
# --------------------------------------------------------------------------
while len(self._messages) >= self._max_queue:
self._put_message_waiter = self._loop.create_future()
try:
Expand Down
3 changes: 1 addition & 2 deletions falcon/bench/dj/dj/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
Django settings for dj project.
"""Django settings for dj project.
Generated by 'django-admin startproject' using Django 1.11.3.
Expand Down
3 changes: 1 addition & 2 deletions falcon/bench/dj/dj/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
"""
WSGI config for dj project.
"""WSGI config for dj project.
It exposes the WSGI callable as a module-level variable named ``application``.
Expand Down
4 changes: 1 addition & 3 deletions falcon/cmd/inspect_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Script that prints out the routes of an App instance.
"""
"""Script that prints out the routes of an App instance."""

import argparse
import importlib
Expand Down
6 changes: 2 additions & 4 deletions falcon/util/structures.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
# TODO(kgriffs): If we ever diverge from what is upstream in Requests,
# then we will need write tests and remove the "no cover" pragma.
class CaseInsensitiveDict(MutableMapping): # pragma: no cover
"""
A case-insensitive ``dict``-like object.
"""A case-insensitive ``dict``-like object.
Implements all methods and operations of
``collections.abc.MutableMapping`` as well as dict's `copy`. Also
Expand Down Expand Up @@ -121,8 +120,7 @@ def __repr__(self) -> str:
# Context is, by design, a bare class, and the mapping interface may be
# removed in a future Falcon release.
class Context:
"""
Convenience class to hold contextual information in its attributes.
"""Convenience class to hold contextual information in its attributes.
This class is used as the default :class:`~.Request` and :class:`~Response`
context type (see
Expand Down
36 changes: 36 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,42 @@
format.quote-style = "single"
line-length = 88
extend-exclude = ["falcon/vendor"]
builtins = [
"ignore",
"attr",
"defined",
]
exclude = [
".ecosystem",
".eggs",
".git",
".tox",
".venv",
"build",
"dist",
"docs",
"examples",
"falcon/bench/nuts",
]

[tool.ruff.lint]
ignore = ["F403"]
select = [
"C9",
"E",
"F",
"W",
]

[tool.ruff.lint.mccabe]
max-complexity = 15

[tool.ruff.lint.per-file-ignores]
"**/__init__.py" = [
"F401",
"E402",
]
"falcon/uri.py" = ["F401"]

[tool.pytest.ini_options]
filterwarnings = [
Expand Down
28 changes: 6 additions & 22 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,8 @@ commands = {[smoke-test]commands}
# --------------------------------------------------------------------

[testenv:pep8]
deps = flake8
flake8-quotes
flake8-import-order
commands = flake8 []
deps = ruff
commands = ruff check []

[testenv:ruff]
deps = ruff>=0.3.7
Expand All @@ -280,29 +278,15 @@ skip_install = True
commands = ruff format . []

[testenv:pep8-docstrings]
deps = flake8
flake8-docstrings
basepython = python3.10
commands = flake8 \
--docstring-convention=pep257 \
deps = ruff
commands = ruff check \
--exclude=.ecosystem,.eggs,.git,.tox,.venv,build,dist,docs,examples,tests,falcon/vendor,falcon/bench/nuts \
--select=D205,D212,D400,D401,D403,D404 \
[]

[testenv:pep8-examples]
deps = flake8
flake8-quotes
flake8-import-order

basepython = python3.10

commands = flake8 examples \
--max-complexity=12 \
--ignore=F403,W503,W504 \
--max-line-length=99 \
--import-order-style=google \
--application-import-names=asgilook,look \
[]
deps = ruff
commands = ruff check examples --line-length=99 []

# --------------------------------------------------------------------
# For viewing environ dicts generated by various WSGI servers
Expand Down

0 comments on commit f3c0019

Please sign in to comment.