diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml new file mode 100644 index 000000000..688134b42 --- /dev/null +++ b/.github/workflows/codespell.yml @@ -0,0 +1,13 @@ +name: Check spelling with codespell + +on: [push, pull_request] + +jobs: + codespell: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + # codespell version should be kept in sync with .pre-commit-config.yml + - run: pip install --user codespell==2.4.1 tomli + - run: codespell + diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 05f5d3df0..0ee16485f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,3 +13,11 @@ repos: hooks: - id: ruff id: ruff-format + + - repo: https://github.com/codespell-project/codespell + rev: v2.4.1 + # version should be kept in sync with .github/workflows/codespell.yml & micropython repo + hooks: + - id: codespell + additional_dependencies: + - tomli diff --git a/micropython/bluetooth/aioble/aioble/central.py b/micropython/bluetooth/aioble/aioble/central.py index 131b1e0db..15ef8aa12 100644 --- a/micropython/bluetooth/aioble/aioble/central.py +++ b/micropython/bluetooth/aioble/aioble/central.py @@ -119,7 +119,7 @@ async def _connect( _connecting.add(device) # Event will be set in the connected IRQ, and then later - # re-used to notify disconnection. + # reused to notify disconnection. connection._event = connection._event or asyncio.ThreadSafeFlag() try: diff --git a/micropython/bluetooth/aioble/aioble/client.py b/micropython/bluetooth/aioble/aioble/client.py index 859c6e937..a3b0efb6e 100644 --- a/micropython/bluetooth/aioble/aioble/client.py +++ b/micropython/bluetooth/aioble/aioble/client.py @@ -244,7 +244,7 @@ async def read(self, timeout_ms=1000): self._register_with_connection() # This will be set by the done IRQ. self._read_status = None - # This will be set by the result and done IRQs. Re-use if possible. + # This will be set by the result and done IRQs. Reuse if possible. self._read_event = self._read_event or asyncio.ThreadSafeFlag() # Issue the read. diff --git a/micropython/espflash/example.py b/micropython/espflash/example.py index 76e8eb84e..ea4a8af95 100644 --- a/micropython/espflash/example.py +++ b/micropython/espflash/example.py @@ -13,7 +13,7 @@ esp = espflash.ESPFlash(reset, gpio0, uart) # Enter bootloader download mode, at 115200 esp.bootloader() - # Can now chage to higher/lower baudrate + # Can now change to higher/lower baudrate esp.set_baudrate(921600) # Must call this first before any flash functions. esp.flash_attach() diff --git a/micropython/senml/examples/custom_record.py b/micropython/senml/examples/custom_record.py index ece866791..90f1ddfdb 100644 --- a/micropython/senml/examples/custom_record.py +++ b/micropython/senml/examples/custom_record.py @@ -32,7 +32,7 @@ class Coordinates(SenmlRecord): def __init__(self, name, **kwargs): """overriding the init function so we can initiate the 3 senml records that will represent lat,lon, alt""" self._lat = SenmlRecord( - "lattitude", unit=SenmlUnits.SENML_UNIT_DEGREES_LATITUDE + "latitude", unit=SenmlUnits.SENML_UNIT_DEGREES_LATITUDE ) # create these before calling base constructor so that all can be init correctly from constructor self._lon = SenmlRecord("longitude", unit=SenmlUnits.SENML_UNIT_DEGREES_LONGITUDE) self._alt = SenmlRecord("altitude", unit=SenmlUnits.SENML_UNIT_METER) diff --git a/micropython/senml/senml/senml_record.py b/micropython/senml/senml/senml_record.py index 9cc260f5b..bbf2730ce 100644 --- a/micropython/senml/senml/senml_record.py +++ b/micropython/senml/senml/senml_record.py @@ -188,7 +188,7 @@ def _build_rec_dict(self, naming_map, appendTo): elif isinstance(self._value, bytearray): if ( naming_map["vd"] == "vd" - ): # neeed to make a distinction between json (needs base64) and cbor (needs binary) + ): # need to make a distinction between json (needs base64) and cbor (needs binary) result[naming_map["vd"]] = binascii.b2a_base64(self._value, newline=False).decode( "utf8" ) diff --git a/pyproject.toml b/pyproject.toml index a309df1f6..8eadf2571 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,14 @@ +[tool.codespell] +count = "" +ignore-regex = '\b[A-Z]{3}\b' +ignore-words-list = "ans,asend,deques,dout,emac,extint,hsi,iput,mis,notin,numer,ser,shft,synopsys,technic,ure,curren,te,bu,curch,ist,clen,henc,shttp,unstall,ody" +quiet-level = 3 +skip = """ +./.git,\ +**/test_*.py,\ +**/html.entities/html/entities.py,\ +""" + [tool.ruff] extend-exclude = [ "python-stdlib", diff --git a/python-ecosys/requests/manifest.py b/python-ecosys/requests/manifest.py index 85f159753..caabb93cb 100644 --- a/python-ecosys/requests/manifest.py +++ b/python-ecosys/requests/manifest.py @@ -1,3 +1,3 @@ -metadata(version="0.10.2", pypi="requests") +metadata(version="0.10.3", pypi="requests") package("requests") diff --git a/python-ecosys/requests/requests/__init__.py b/python-ecosys/requests/requests/__init__.py index 4ca7489a4..68b4b18cb 100644 --- a/python-ecosys/requests/requests/__init__.py +++ b/python-ecosys/requests/requests/__init__.py @@ -56,9 +56,9 @@ def request( import binascii username, password = auth - formated = b"{}:{}".format(username, password) - formated = str(binascii.b2a_base64(formated)[:-1], "ascii") - headers["Authorization"] = "Basic {}".format(formated) + formatted = b"{}:{}".format(username, password) + formatted = str(binascii.b2a_base64(formatted)[:-1], "ascii") + headers["Authorization"] = "Basic {}".format(formatted) try: proto, dummy, host, path = url.split("/", 3) diff --git a/python-stdlib/hmac/test_hmac.py b/python-stdlib/hmac/test_hmac.py index 1cfcf4e37..bb6effc4b 100644 --- a/python-stdlib/hmac/test_hmac.py +++ b/python-stdlib/hmac/test_hmac.py @@ -1,3 +1,4 @@ +# codespell:ignore import hmac # Uncomment to use micropython-lib hashlib (supports sha512) diff --git a/unix-ffi/email.parser/email/parser.py b/unix-ffi/email.parser/email/parser.py index 760adeff5..7053d0734 100644 --- a/unix-ffi/email.parser/email/parser.py +++ b/unix-ffi/email.parser/email/parser.py @@ -23,7 +23,7 @@ def __init__(self, _class=Message, policy=compat32): textual representation of the message. The string must be formatted as a block of RFC 2822 headers and header - continuation lines, optionally preceeded by a `Unix-from' header. The + continuation lines, optionally preceded by a `Unix-from' header. The header block is terminated either by the end of the string or by a blank line. @@ -85,7 +85,7 @@ def __init__(self, *args, **kw): textual representation of the message. The input must be formatted as a block of RFC 2822 headers and header - continuation lines, optionally preceeded by a `Unix-from' header. The + continuation lines, optionally preceded by a `Unix-from' header. The header block is terminated either by the end of the input or by a blank line. diff --git a/unix-ffi/html.parser/html/parser.py b/unix-ffi/html.parser/html/parser.py index 74b39d49a..571b42a34 100644 --- a/unix-ffi/html.parser/html/parser.py +++ b/unix-ffi/html.parser/html/parser.py @@ -445,7 +445,7 @@ def parse_endtag(self, i): tagname = namematch.group().lower() # consume and ignore other stuff between the name and the > # Note: this is not 100% correct, since we might have things like - # , but looking for > after tha name should cover + # , but looking for > after the name should cover # most of the cases and is much simpler gtpos = rawdata.find(">", namematch.end()) self.handle_endtag(tagname) diff --git a/unix-ffi/http.client/http/client.py b/unix-ffi/http.client/http/client.py index 856848283..18c1f3319 100644 --- a/unix-ffi/http.client/http/client.py +++ b/unix-ffi/http.client/http/client.py @@ -1038,10 +1038,10 @@ def putrequest(self, method, url, skip_host=0, skip_accept_encoding=0): self.putheader("Accept-Encoding", "identity") # we can accept "chunked" Transfer-Encodings, but no others - # NOTE: no TE header implies *only* "chunked" + # NOTE: no 'TE' header implies *only* "chunked" # self.putheader('TE', 'chunked') - # if TE is supplied in the header, then it must appear in a + # if 'TE' is supplied in the header, then it must appear in a # Connection header. # self.putheader('Connection', 'TE')