Skip to content

Commit

Permalink
[PR #7775/5f64328c backport][3.9] Add codespell support: pre-commit e…
Browse files Browse the repository at this point in the history
…ntry, configuration, some typoes get fixed (#7800)

**This is a backport of PR #7775 as merged into master
(5f64328).**

## What do these changes do?

See https://github.com/codespell-project/codespell for the codespell
project. I like it and promote everywhere I go ;)

but feel free to disregard this PR, may be take just last commit with 1
obvious typo and may be the "repr" typo fix.

Another commit fixes typos it found and some were I guess whitelisted in
docs/spelling_wordlist.txt where it fixed them too. What is the role/how
that file is used? (I am not familiar, but found similar ones in
jsonschema and few other projects)

## Are there changes in behavior for the user?

somewhat since there is following fix

```
         if t is None:
-            t_repr = "<<Unkown>>"
+            t_repr = "<<Unknown>>"
```

so some reprs would be effected . another change is functional in the
test (taking "an" not "ans" from "answer") but that must not be user
visible

please advise on either you see value for me to bother with CHANGES etc

## Checklist

- [ ] I think the code is well written
- [ ] Unit tests for the changes exist
- [ ] Documentation reflects the changes
- [ ] If you provide code modification, please add yourself to
`CONTRIBUTORS.txt`
  * The format is &lt;Name&gt; &lt;Surname&gt;.
  * Please keep alphabetical order, the file is sorted by names.
- [ ] Add a new news fragment into the `CHANGES` folder
  * name it `<issue_id>.<type>` for example (588.bugfix)
* if you don't have an `issue_id` change it to the pr id after creating
the pr
  * ensure type is one of the following:
    * `.feature`: Signifying a new feature.
    * `.bugfix`: Signifying a bug fix.
    * `.doc`: Signifying a documentation improvement.
    * `.removal`: Signifying a deprecation or removal of public API.
* `.misc`: A ticket has been closed, but it is not of interest to users.
* Make sure to use full sentences with correct case and punctuation, for
example: "Fix issue with non-ascii contents in doctest text files."

Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>
  • Loading branch information
patchback[bot] and yarikoptic authored Nov 9, 2023
1 parent ff40908 commit fffc433
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 24 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ repos:
^[^/]+[.]rst$
exclude: >-
^CHANGES\.rst$
- repo: https://github.com/codespell-project/codespell
rev: v2.2.6
hooks:
- id: codespell
additional_dependencies:
- tomli
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ Workflow is pretty straightforward:
.. important::

Please open the "`contributing <https://docs.aiohttp.org/en/stable/contributing.html>`_"
documentation page to get detailed informations about all steps.
documentation page to get detailed information about all steps.

.. _GitHub: https://github.com/aio-libs/aiohttp
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,7 @@ async def read(self) -> bytes:
except BaseException:
self.close()
raise
elif self._released: # Response explicity released
elif self._released: # Response explicitly released
raise ClientConnectionError("Connection closed")

await self._wait_released() # Underlying connection released
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ def _release_waiter(self) -> None:
"""
Iterates over all waiters until one to be released is found.
The one to be released is not finsihed and
The one to be released is not finished and
belongs to a host that has available connections.
"""
if not self._waiters:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ def __repr__(self) -> str:
t = get_args(self.__orig_class__)[0]

if t is None:
t_repr = "<<Unkown>>"
t_repr = "<<Unknown>>"
elif isinstance(t, type):
if t.__module__ == "builtins":
t_repr = t.__qualname__
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ def feed_data(

# if stream does not contain trailer, after 0\r\n
# we should get another \r\n otherwise
# trailers needs to be skiped until \r\n\r\n
# trailers needs to be skipped until \r\n\r\n
if self._chunk == ChunkState.PARSE_MAYBE_TRAILERS:
head = chunk[: len(SEP)]
if head == SEP:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ def __bool__(self) -> bool:
def _boundary_value(self) -> str:
"""Wrap boundary parameter value in quotes, if necessary.
Reads self.boundary and returns a unicode sting.
Reads self.boundary and returns a unicode string.
"""
# Refer to RFCs 7231, 7230, 5234.
#
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/payload_streamer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Payload implemenation for coroutines as data provider.
Payload implementation for coroutines as data provider.
As a simple case, you can upload data from file::
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def end_http_chunk_receiving(self) -> None:
# self._http_chunk_splits contains logical byte offsets from start of
# the body transfer. Each offset is the offset of the end of a chunk.
# "Logical" means bytes, accessible for a user.
# If no chunks containig logical data were received, current position
# If no chunks containing logical data were received, current position
# is difinitely zero.
pos = self._http_chunk_splits[-1] if self._http_chunk_splits else 0

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
def loop(self) -> asyncio.AbstractEventLoop:
# Technically the loop can be None
# but we mask it by explicit type cast
# to provide more convinient type annotation
# to provide more convenient type annotation
warnings.warn("loop property is deprecated", DeprecationWarning, stacklevel=2)
return cast(asyncio.AbstractEventLoop, self._loop)

Expand Down
2 changes: 1 addition & 1 deletion docs/abc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ but few of them are.
aiohttp.web is built on top of few concepts: *application*, *router*,
*request* and *response*.

*router* is a *plugable* part: a library user may build a *router*
*router* is a *pluggable* part: a library user may build a *router*
from scratch, all other parts should work with new router seamlessly.

:class:`aiohttp.abc.AbstractRouter` has the only mandatory method:
Expand Down
2 changes: 1 addition & 1 deletion docs/client_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ endpoints of ``http://httpbin.org`` can be used the following code::
every request is a **very bad** idea.

A session contains a connection pool inside. Connection reusage and
keep-alives (both are on by default) may speed up total performance.
keep-alive (both are on by default) may speed up total performance.

A session context manager usage is not mandatory
but ``await session.close()`` method
Expand Down
2 changes: 1 addition & 1 deletion docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1332,7 +1332,7 @@ Response object
Reading from the stream may raise
:exc:`aiohttp.ClientPayloadError` if the response object is
closed before response receives all data or in case if any
transfer encoding related errors like misformed chunked
transfer encoding related errors like malformed chunked
encoding of broken compression data.

.. attribute:: cookies
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ and call :meth:`aiohttp.web.WebSocketResponse.close` on all of them in
for ws in request.app[websockets_key][user_id]
if not ws.closed]

# Watch out, this will keep us from returing the response
# Watch out, this will keep us from returning the response
# until all are closed
ws_closers and await asyncio.gather(*ws_closers)

Expand Down
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Key Features
:ref:`Client WebSockets <aiohttp-client-websockets>` out-of-the-box
without the Callback Hell.
- Web-server has :ref:`aiohttp-web-middlewares`,
:ref:`aiohttp-web-signals` and plugable routing.
:ref:`aiohttp-web-signals` and pluggable routing.

.. _aiohttp-installation:

Expand Down
4 changes: 1 addition & 3 deletions docs/spelling_wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ middleware
middlewares
miltidict
misbehaviors
misformed
Mixcloud
Mongo
Mongo
Expand Down Expand Up @@ -223,7 +222,7 @@ performant
pickleable
ping
pipelining
plugable
pluggable
plugin
poller
pong
Expand Down Expand Up @@ -284,7 +283,6 @@ shourtcuts
skipuntil
Skyscanner
SocketSocketTransport
softwares
ssl
SSLContext
startup
Expand Down
2 changes: 1 addition & 1 deletion docs/web_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ Resource in turn has at least one *route*.

Route corresponds to handling *HTTP method* by calling *web handler*.

Thus when you add a *route* the *resouce* object is created under the hood.
Thus when you add a *route* the *resource* object is created under the hood.

The library implementation **merges** all subsequent route additions
for the same path adding the only resource for all HTTP methods.
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ issue_format = "`#{issue} <https://github.com/aio-libs/aiohttp/issues/{issue}>`_
test-command = ""
# don't build PyPy wheels, install from source instead
skip = "pp*"

[tool.codespell]
skip = '.git,*.pdf,*.svg,Makefile,CONTRIBUTORS.txt,venvs,_build'
ignore-words-list = 'te'
4 changes: 2 additions & 2 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -2046,7 +2046,7 @@ async def handler(request):

async def test_payload_content_length_by_chunks(aiohttp_client) -> None:
async def handler(request):
resp = web.StreamResponse(headers={"content-length": "3"})
resp = web.StreamResponse(headers={"content-length": "2"})
await resp.prepare(request)
await resp.write(b"answer")
await resp.write(b"two")
Expand All @@ -2059,7 +2059,7 @@ async def handler(request):

resp = await client.get("/")
data = await resp.read()
assert data == b"ans"
assert data == b"an"
resp.close()


Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def stream():
return mock.Mock()


@pytest.mark.skipif(NO_EXTENSIONS, reason="Extentions available but not imported")
@pytest.mark.skipif(NO_EXTENSIONS, reason="Extensions available but not imported")
def test_c_parser_loaded():
assert "HttpRequestParserC" in dir(aiohttp.http_parser)
assert "HttpResponseParserC" in dir(aiohttp.http_parser)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def protocol():
def get_memory_usage(obj):
objs = [obj]
# Memory leak may be caused by leaked links to same objects.
# Without link counting, [1,2,3] is indistiguishable from [1,2,3,3,3,3,3,3]
# Without link counting, [1,2,3] is indistinguishable from [1,2,3,3,3,3,3,3]
known = defaultdict(int)
known[id(obj)] += 1

Expand Down
4 changes: 2 additions & 2 deletions tests/test_web_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -911,9 +911,9 @@ def test_cookie_set_after_del() -> None:
def test_set_status_with_reason() -> None:
resp = StreamResponse()

resp.set_status(200, "Everithing is fine!")
resp.set_status(200, "Everything is fine!")
assert 200 == resp.status
assert "Everithing is fine!" == resp.reason
assert "Everything is fine!" == resp.reason


async def test_start_force_close() -> None:
Expand Down

0 comments on commit fffc433

Please sign in to comment.