From 29041014a531835bf9b6a80ca9d7ed414a929432 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 16 Sep 2020 22:24:02 +0000 Subject: [PATCH] Start checking codebase with the codespell tool Use master branch tip of codespell for now, until it supports configuration in the included .codespellrc in a released version. Also correct things its default dictionary selection identified as misspellings, with the exception of intentional misspellings in the sample spelling correction config and selftest which exercises it. --- .codespellrc | 7 +++++++ doc/source/coder.rst | 2 +- mudpy/misc.py | 8 ++++---- mudpy/telnet.py | 4 ++-- share/command.yaml | 4 ++-- tox.ini | 12 +++++++++++- 6 files changed, 27 insertions(+), 10 deletions(-) create mode 100644 .codespellrc diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..5efcde7 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,7 @@ +# Copyright (c) 2020 mudpy authors. Permission to use, copy, +# modify, and distribute this software is granted under terms +# provided in the LICENSE file distributed with this software. + +[codespell] +ignore-words-list = files',wont,teh,theyre,youre +skip = *.pyc,.eggs,.git,.tox,build diff --git a/doc/source/coder.rst b/doc/source/coder.rst index 0e5bcae..b3ed6da 100644 --- a/doc/source/coder.rst +++ b/doc/source/coder.rst @@ -125,7 +125,7 @@ cloned it:: Now you should be able to invoke any tox testenv you like. Just running :command:`tox` without any additional options will go -through the defalt battery of checks and is a good way to make sure +through the default battery of checks and is a good way to make sure everything is installed and working. Once you're ready to try out the server interactively, launch it like this:: diff --git a/mudpy/misc.py b/mudpy/misc.py index 074f538..ba29a90 100644 --- a/mudpy/misc.py +++ b/mudpy/misc.py @@ -1084,7 +1084,7 @@ def get_loglines(level, start, stop): # don't proceed if there are no lines if filtered_count: - # can't start before the begining or at the end + # can't start before the beginning or at the end if start > filtered_count: start = filtered_count if start < 1: @@ -1137,7 +1137,7 @@ def wrap_ansi_text(text, width): # characters, printable or otherwise abs_pos = 0 - # the current text position relative to the begining of the line, + # the current text position relative to the beginning of the line, # ignoring color escape sequences rel_pos = 0 @@ -1152,7 +1152,7 @@ def wrap_ansi_text(text, width): # normalize any potentially composited unicode before we count it text = unicodedata.normalize("NFKC", text) - # iterate over each character from the begining of the text + # iterate over each character from the beginning of the text for each_character in text: # the current character is the escape character @@ -1194,7 +1194,7 @@ def wrap_ansi_text(text, width): # characters but the space it replaced was only one abs_pos += 1 - # now we're at the begining of a new line, plus the + # now we're at the beginning of a new line, plus the # number of characters wrapped from the previous line rel_pos -= last_rel_whitespace last_rel_whitespace = 0 diff --git a/mudpy/telnet.py b/mudpy/telnet.py index 73331b9..ec18f70 100644 --- a/mudpy/telnet.py +++ b/mudpy/telnet.py @@ -188,7 +188,7 @@ def negotiate_telnet_options(user): # make a local copy to play with text = user.partial_input - # start at the begining of the input + # start at the beginning of the input position = 0 # as long as we haven't checked it all @@ -283,7 +283,7 @@ def negotiate_telnet_options(user): log("Ignored unknown command %s from" % command, user) text = text[:position] + text[position + 2:] - # and this means we got the begining of an IAC + # and this means we got the beginning of an IAC else: position += 1 diff --git a/share/command.yaml b/share/command.yaml index 10a0cdf..0f4df40 100644 --- a/share/command.yaml +++ b/share/command.yaml @@ -1,5 +1,5 @@ --- -_copy: Copyright (c) 2004-2019 mudpy authors. Permission to use, copy, +_copy: Copyright (c) 2004-2020 mudpy authors. Permission to use, copy, modify, and distribute this software is granted under terms provided in the LICENSE file distributed with this software. @@ -36,7 +36,7 @@ command.halt.help: This will save all active accounts, disconnect all clients and stop the entire program. command.help.description: List commands or get help on one. -command.help.help: This will list all comand words available to you along with +command.help.help: This will list all command words available to you along with a brief description or, alternatively, give you detailed information on one command. diff --git a/tox.ini b/tox.ini index d57c0d7..1ede200 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ [tox] minversion = 3.1 -envlist = bandit, dist, docs, flake8, yamllint, selftest_config, py3 +envlist = bandit, codespell, dist, docs, flake8, yamllint, selftest_config, py3 skipsdist = True ignore_basepython_conflict = True @@ -26,6 +26,16 @@ deps = bandit commands = bandit -r mudpy -x mudpy/tests {posargs} usedevelop = False +[testenv:codespell] +# TODO(fungi) switch to a proper PyPI dep once .codespellrc is supported in a +# release version, and ratchet down deprecation warnings for it at that point +#setenv = +# PYTHONWARNINGS=error +#deps = codespell +deps = git+https://github.com/codespell-project/codespell +commands = codespell {posargs} +usedevelop = False + [testenv:demo] commands = mudpy {posargs} -- 2.11.0