Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add codespell support (config, workflow to detect/not fix) and make it fix few typos #278

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Codespell configuration is within setup.cfg
---
name: Codespell

on:
push:
branches: [master]
pull_request:
branches: [master]

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Annotate locations with typos
uses: codespell-project/codespell-problem-matcher@v1
- name: Codespell
uses: codespell-project/actions-codespell@v2
2 changes: 1 addition & 1 deletion bin/display-fpathconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def display_fpathconf():
# VEOF EOF ^D
# VEOL EOL _POSIX_VDISABLE
#
# irregardless, this value is almost always \xff.
# regardless, this value is almost always \xff.
('PC_VDISABLE', 'Terminal character disabling value.')
)
fmt = '{name:<13} {value:<10} {description:<11}'
Expand Down
4 changes: 2 additions & 2 deletions bin/display-maxcanon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
as if it is always set." Although these tests ensure it is enabled, this is a non-op for Linux.

FreeBSD supports neither, and instead uses a fraction (1/5) of the tty speed which is always 9600.
Therefor, the maximum limited input line length is 9600 / 5 = 1920.
Therefore, the maximum limited input line length is 9600 / 5 = 1920.

In other words, the only way to determine the true MAX_CANON in a cross-platform manner is through
this systems integrated test: the given system definitions are misleading on some operating systems.
Expand All @@ -30,7 +30,7 @@ def detect_maxcanon():
"""Program entry point."""
import pexpect
bashrc = os.path.join(
# re-use pexpect/replwrap.py's bashrc file,
# reuse pexpect/replwrap.py's bashrc file,
os.path.dirname(__file__), os.path.pardir, 'pexpect', 'bashrc.sh')

child = pexpect.spawn('bash', ['--rcfile', bashrc],
Expand Down
2 changes: 1 addition & 1 deletion bin/display-terminalinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def display_bitmask(kind, bitmap, value):


def display_ctl_chars(index, ctlc):
"""Display all control character indicies, names, and values."""
"""Display all control character indices, names, and values."""
import termios
title = 'Special Character'
col1_width = len(title)
Expand Down
2 changes: 1 addition & 1 deletion bin/strip.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
"""Example scrip that strips input of terminal sequences."""
"""Example script that strips input of terminal sequences."""
# std imports
import sys

Expand Down
4 changes: 2 additions & 2 deletions blessed/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,15 @@ def get_proxy_string(term, attr):

def split_compound(compound):
"""
Split compound formating string into segments.
Split compound formatting string into segments.

>>> split_compound('bold_underline_bright_blue_on_red')
['bold', 'underline', 'bright_blue', 'on_red']

:arg str compound: a string that may contain compounds, separated by
underline (``_``).
:rtype: list
:returns: List of formating string segments
:returns: List of formatting string segments
"""
merged_segs = []
# These occur only as prefixes, so they can always be merged:
Expand Down
6 changes: 3 additions & 3 deletions blessed/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def width(self):
@property
def pixel_height(self):
"""
Read-only property: Height ofthe terminal (in pixels).
Read-only property: Height of the terminal (in pixels).

:rtype: int
"""
Expand Down Expand Up @@ -578,7 +578,7 @@ def location(self, x=None, y=None):

.. note:: The argument order *(x, y)* differs from the return value order *(y, x)*
of :meth:`get_location`, or argument order *(y, x)* of :meth:`move`. This is
for API Compaibility with the blessings library, sorry for the trouble!
for API Compatibility with the blessings library, sorry for the trouble!
"""
# pylint: disable=invalid-name
# Invalid argument name "x"
Expand Down Expand Up @@ -1250,7 +1250,7 @@ def getch(self):
the keyboard string at a time. This method should always return
without blocking if called after :meth:`kbhit` has returned True.

Implementors of alternate input stream methods should override
Implementers of alternate input stream methods should override
this method.
"""
assert self._keyboard_fd is not None
Expand Down
2 changes: 1 addition & 1 deletion docs/keyboard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ It is therefore a recommendation to **avoid alt or meta keys entirely** in appli
And instead prefer the ctrl-key combinations, maybe along with :meth:`~.Terminal.raw`, to avoid
instructing users to custom-configure their terminal emulators to communicate *Alt* sequences.

If you still wish to optionall decode them, *ALT+z* becomes *Escape + z* (or, in raw form
If you still wish to optionally decode them, *ALT+z* becomes *Escape + z* (or, in raw form
``\x1bz``). This is detected by blessings as two keystrokes, ``KEY_ESCAPE`` and ``'z'``. Blessings
currently provides no further assistance in detecting these key combinations.

Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,10 @@ ignore_missing_imports = True

[mypy-wcwidth.*]
ignore_missing_imports = True

[codespell]
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
skip = .git*,MANIFEST.in
check-hidden = true
ignore-regex = \b(iTerm|THIRDPARTY)\b|/Softwares/
ignore-words-list = padd,parms
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def test_time_left_infinite_None():
assert _time_left(stime=time.time(), timeout=None) is None


@pytest.mark.skipif(IS_WINDOWS, reason="cant multiprocess")
@pytest.mark.skipif(IS_WINDOWS, reason="can't multiprocess")
def test_termcap_repr():
"""Ensure ``hidden_cursor()`` writes hide_cursor and normal_cursor."""

Expand Down
2 changes: 1 addition & 1 deletion tests/test_full_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def test_keystroke_0s_cbreak_multibyte_utf8():
assert math.floor(time.time() - stime) == 0.0


# Avylove: Added delay which should account for race contition. Re-add skip if randomly fail
# Avylove: Added delay which should account for race condition. Re-add skip if randomly fail
# @pytest.mark.skipif(os.environ.get('TRAVIS', None) is not None,
# reason="travis-ci does not handle ^C very well.")
@pytest.mark.skipif(platform.system() == 'Darwin',
Expand Down
4 changes: 2 additions & 2 deletions tests/test_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def child():

def test_notty_kb_is_None():
"""term._keyboard_fd should be None when os.isatty returns False."""
# in this scenerio, stream is sys.__stdout__,
# in this scenario, stream is sys.__stdout__,
# but os.isatty(0) is False,
# such as when piping output to less(1)
@as_subprocess
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_resolve_sequence():
# takes precedence over LONGSEQ, first-match
(u'KEY_LONGSEQ_longest', 3),
(u'LONGSEQ', 4),
# wont match, LONGSEQ is first-match in this order
# won't match, LONGSEQ is first-match in this order
(u'LONGSEQ_longer', 5),
# falls through for L{anything_else}
(u'L', 6)))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_length_sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ def child(kind):
assert (term.length(term.cud(10)) == 0)

# this is how manpages perform underlining, this is done
# with the 'overstrike' capability of teletypes, and aparently
# with the 'overstrike' capability of teletypes, and apparently
# less(1), '123' -> '1\b_2\b_3\b_'
text_wseqs = u''.join(itertools.chain(
*zip(plain_text, itertools.cycle(['\b_']))))
Expand Down