From 5f64328cb4aa4e551090c2a4d52334d0fc529ad3 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Tue, 7 Nov 2023 14:41:12 -0500 Subject: [PATCH] Add codespell support: pre-commit entry, configuration, some typoes get fixed (#7775) ## 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 = "<>" + t_repr = "<>" ``` 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 <Name> <Surname>. * Please keep alphabetical order, the file is sorted by names. - [ ] Add a new news fragment into the `CHANGES` folder * name it `.` 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: Sviatoslav Sydorenko --- .pre-commit-config.yaml | 6 ++++++ aiohttp/client_reqrep.py | 2 +- aiohttp/helpers.py | 2 +- aiohttp/http_parser.py | 2 +- docs/abc.rst | 2 +- docs/client_quickstart.rst | 2 +- docs/client_reference.rst | 2 +- docs/index.rst | 2 +- docs/spelling_wordlist.txt | 4 +--- pyproject.toml | 4 ++++ tests/test_client_functional.py | 4 ++-- 11 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 263eaf63a80..ecee22c0019 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 8271f70e445..f509b55e5ad 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -1019,7 +1019,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 diff --git a/aiohttp/helpers.py b/aiohttp/helpers.py index 19710e15edc..de2f538927d 100644 --- a/aiohttp/helpers.py +++ b/aiohttp/helpers.py @@ -848,7 +848,7 @@ def __repr__(self) -> str: t = get_args(self.__orig_class__)[0] if t is None: - t_repr = "<>" + t_repr = "<>" elif isinstance(t, type): if t.__module__ == "builtins": t_repr = t.__qualname__ diff --git a/aiohttp/http_parser.py b/aiohttp/http_parser.py index b218ec50abe..b3462d5db55 100644 --- a/aiohttp/http_parser.py +++ b/aiohttp/http_parser.py @@ -867,7 +867,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: diff --git a/docs/abc.rst b/docs/abc.rst index 137ad218eaf..ee19a0915d1 100644 --- a/docs/abc.rst +++ b/docs/abc.rst @@ -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: diff --git a/docs/client_quickstart.rst b/docs/client_quickstart.rst index 50b1c252f22..eea1bba9a54 100644 --- a/docs/client_quickstart.rst +++ b/docs/client_quickstart.rst @@ -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. You may find more information about creating persistent sessions in :ref:`aiohttp-persistent-session`. diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 4c89351e841..805e16a2bcb 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -1316,7 +1316,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 diff --git a/docs/index.rst b/docs/index.rst index a7a7d477c72..a9854c07ece 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -22,7 +22,7 @@ Key Features :ref:`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: diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 7c1de5cb769..b1cd28e6842 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -182,7 +182,6 @@ middleware middlewares miltidict misbehaviors -misformed Mixcloud Mongo msg @@ -223,7 +222,7 @@ performant pickleable ping pipelining -plugable +pluggable plugin poller pong @@ -285,7 +284,6 @@ shourtcuts skipuntil Skyscanner SocketSocketTransport -softwares ssl SSLContext startup diff --git a/pyproject.toml b/pyproject.toml index 262623fecd5..1f590d002ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,3 +17,7 @@ issue_format = "`#{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' diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py index ca976b45a37..38983244097 100644 --- a/tests/test_client_functional.py +++ b/tests/test_client_functional.py @@ -2014,7 +2014,7 @@ async def handler(request): async def test_payload_content_length_by_chunks(aiohttp_client: Any) -> 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") @@ -2027,7 +2027,7 @@ async def handler(request): resp = await client.get("/") data = await resp.read() - assert data == b"ans" + assert data == b"an" resp.close()