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 configuration. #2057

Merged
merged 2 commits into from
Jul 31, 2023
Merged
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
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ repos:
rev: 6.1.0
hooks:
- id: flake8
- repo: https://github.com/codespell-project/codespell
rev: v2.2.5
hooks:
- id: codespell
additional_dependencies:
- tomli
2 changes: 1 addition & 1 deletion changes/1956.removal.rst
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Images and ImageViews no longer support loading images from URLs. If you need to display an image from a URL, use a background task to obtain the image data asynchronously, then create the Image and/or set the ImageView ``image`` property on the completion of the asychronous load.
Images and ImageViews no longer support loading images from URLs. If you need to display an image from a URL, use a background task to obtain the image data asynchronously, then create the Image and/or set the ImageView ``image`` property on the completion of the asynchronous load.
1 change: 1 addition & 0 deletions changes/2057.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Codespell was added to the pre-commit configuration.
2 changes: 1 addition & 1 deletion cocoa/src/toga_cocoa/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, widget):
self.left_constraint = None
self.top_constraint = None

# Deletion isn't an event we can programatically invoke; deletion
# Deletion isn't an event we can programmatically invoke; deletion
# of constraints can take several iterations before it occurs.
def __del__(self): # pragma: nocover
self._remove_constraints()
Expand Down
2 changes: 1 addition & 1 deletion cocoa/src/toga_cocoa/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def refreshed(self):

class MinimumContainer(BaseContainer):
def __init__(self):
"""A container for evaluating the minumum possible size for a layout"""
"""A container for evaluating the minimum possible size for a layout"""
super().__init__()
self.width = 0
self.height = 0
Expand Down
2 changes: 1 addition & 1 deletion core/src/toga/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ def fill_rule(self, fill_rule):
fill_rule = FillRule[fill_rule.upper()]
except KeyError:
raise ValueError(
"fill rule should be one of the followings: {}".format(
"fill rule should be one of the following: {}".format(
", ".join([value.name.lower() for value in FillRule])
)
)
Expand Down
2 changes: 1 addition & 1 deletion core/src/toga/widgets/numberinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def min(self, new_min):
try:
new_min = _clean_decimal(new_min, self.step)

# Clip widget's value to the new minumum
# Clip widget's value to the new minimum
if self.value is not None and self.value < new_min:
self.value = new_min
except (TypeError, ValueError, InvalidOperation):
Expand Down
2 changes: 1 addition & 1 deletion core/src/toga/widgets/slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(
if range is not None:
if min is not None or max is not None:
raise ValueError(
"range cannot be specifed if min and max are specified"
"range cannot be specified if min and max are specified"
)
else:
warnings.warn(
Expand Down
6 changes: 3 additions & 3 deletions core/tests/sources/test_list_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_tuples():
# Set element 1
source[1] = ("new element", 999)

# source is the same size, but has differen data
# source is the same size, but has different data
assert len(source) == 3
assert source[1].val1 == "new element"
assert source[1].val2 == 999
Expand Down Expand Up @@ -134,7 +134,7 @@ def test_list():
# Set element 1
source[1] = ["new element", 999]

# source is the same size, but has differen data
# source is the same size, but has different data
assert len(source) == 3
assert source[1].val1 == "new element"
assert source[1].val2 == 999
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_dict():
# Set element 1
source[1] = ["new element", 999]

# source is the same size, but has differen data
# source is the same size, but has different data
assert len(source) == 3
assert source[1].val1 == "new element"
assert source[1].val2 == 999
Expand Down
8 changes: 4 additions & 4 deletions core/tests/style/pack/layout/test_fixed.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_row_expanding_intrinsic():
),
ExampleNode(
"third",
style=Pack(width=0, height=0), # Explictly 0 sized
style=Pack(width=0, height=0), # Explicitly 0 sized
size=(at_least(0), at_least(0)),
),
],
Expand Down Expand Up @@ -143,7 +143,7 @@ def test_row_fixed_intrinsic():
),
],
),
ExampleNode( # Explictly 0 sized
ExampleNode( # Explicitly 0 sized
"third",
style=Pack(),
size=(0, 0),
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_column_expanding_intrinsic():
),
],
),
ExampleNode( # Explictly 0 sized
ExampleNode( # Explicitly 0 sized
"third",
style=Pack(width=0, height=0),
size=(at_least(0), at_least(0)),
Expand Down Expand Up @@ -370,7 +370,7 @@ def test_column_fixed_intrinsic():
),
],
),
ExampleNode( # Explictly 0 sized
ExampleNode( # Explicitly 0 sized
"third",
style=Pack(),
size=(0, 0),
Expand Down
2 changes: 1 addition & 1 deletion core/tests/style/pack/layout/test_flex.py
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ def test_column_flex():

def test_column_flex_insufficient_space():
"""Children in a column layout with flexible containers, but insufficient space to
accomodate them, and an explicit intrinsic width, doesn't collapse column width.
accommodate them, and an explicit intrinsic width, doesn't collapse column width.
"""

root = ExampleNode(
Expand Down
2 changes: 1 addition & 1 deletion core/tests/test_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def run_app(args, cwd):
text=True,
)
# When called as a subprocess, coverage drops it's coverage report in CWD.
# Move it to the projet root for combination with the main test report.
# Move it to the project root for combination with the main test report.
for file in cwd.glob(".coverage*"):
os.rename(file, Path(__file__).parent.parent / file.name)
return output
Expand Down
2 changes: 1 addition & 1 deletion core/tests/widgets/test_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def fill_context():

self.assertRaisesRegex(
ValueError,
"^fill rule should be one of the followings: evenodd, nonzero$",
"^fill rule should be one of the following: evenodd, nonzero$",
fill_context,
)
self.assertActionNotPerformed(self.testing_canvas, "fill")
Expand Down
2 changes: 1 addition & 1 deletion core/tests/widgets/test_multilinetextinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_placeholder(widget, value, expected):


def test_scroll(widget):
"""The widget can be scrolled programatically."""
"""The widget can be scrolled programmatically."""
# Clear the event log
EventLog.reset()

Expand Down
6 changes: 3 additions & 3 deletions core/tests/widgets/test_slider.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,21 +509,21 @@ def test_deprecated():
# Can't specify min and range
with pytest.raises(
ValueError,
match=r"range cannot be specifed if min and max are specified",
match=r"range cannot be specified if min and max are specified",
):
toga.Slider(min=2, range=(2, 4))

# Can't specify max and range
with pytest.raises(
ValueError,
match=r"range cannot be specifed if min and max are specified",
match=r"range cannot be specified if min and max are specified",
):
toga.Slider(max=4, range=(2, 4))

# Can't specify min and max and range
with pytest.raises(
ValueError,
match=r"range cannot be specifed if min and max are specified",
match=r"range cannot be specified if min and max are specified",
):
toga.Slider(min=2, max=4, range=(2, 4))

Expand Down
4 changes: 2 additions & 2 deletions core/tests/widgets/test_webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@ def test_evaluate_javascript(widget):


async def test_evaluate_javascript_async(widget):
"Javascript can be evaluated asyncronously, and an asynchronous result returned"
"Javascript can be evaluated asynchronously, and an asynchronous result returned"

# An async task that simulates evaluation of javasript after a delay
# An async task that simulates evaluation of Javascript after a delay
async def delayed_page_load():
await asyncio.sleep(0.1)

Expand Down
2 changes: 1 addition & 1 deletion examples/beeliza/beeliza/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class Eliza:

###########################################################################
# reflect: take an input string, and reflect the direction of any
# statments (i.e., "I think I'm happy" - > "you think you're happy")
# statements (i.e., "I think I'm happy" - > "you think you're happy")
###########################################################################
def reflect(self, input):
return " ".join(
Expand Down
2 changes: 1 addition & 1 deletion examples/dialogs/dialogs/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async def action_error_dialog(self, widget):
await self.main_window.error_dialog(
"Toga", "Well that didn't work... or did it?"
)
self.label.text = "Oh noes..."
self.label.text = "Oh no..."

async def action_stack_trace(self, widget):
await self.main_window.stack_trace_dialog(
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/toga_gtk/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def recompute(self):
if self._content and self.needs_redraw:
# If any of the widgets have been marked as dirty,
# recompute their bounds, and re-evaluate the minimum
# allowed size fo the layout.
# allowed size for the layout.
while self._dirty_widgets:
widget = self._dirty_widgets.pop()
widget.rehint()
Expand Down
4 changes: 2 additions & 2 deletions gtk/src/toga_gtk/widgets/multilinetextinput.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def create(self):

# The GTK TextView doesn't have an implementation of placeholder. We
# fake it by using a different buffer that contains placeholder text.
# This bufer is installed by default, until the value for the widget
# This buffer is installed by default, until the value for the widget
# becomes something non-empty. The placeholder buffer is also swapped
# out when focus is gained, or a key press event occurs. The latter
# is needed because the value can be changed programatically when
# is needed because the value can be changed programmatically when
# the widget already has focus.
self.placeholder = Gtk.TextBuffer()
self.tag_placeholder = self.placeholder.create_tag(
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/toga_gtk/widgets/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def gtk_on_select(self, selection):
else:
tree_model, tree_iter = selection.get_selected()

# Covert the tree iter into the actual row.
# Convert the tree iter into the actual row.
if tree_iter:
row = tree_model.get(tree_iter, 0)[0]
else:
Expand Down
2 changes: 1 addition & 1 deletion gtk/src/toga_gtk/widgets/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def gtk_on_select(self, selection):
else:
tree_model, tree_iter = selection.get_selected()

# Covert the tree iter into the actual node.
# Convert the tree iter into the actual node.
if tree_iter:
node = tree_model.get(tree_iter, 0)[0]
else:
Expand Down
2 changes: 1 addition & 1 deletion iOS/src/toga_iOS/constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, widget):
self.left_constraint = None
self.top_constraint = None

# Deletion isn't an event we can programatically invoke; deletion
# Deletion isn't an event we can programmatically invoke; deletion
# of constraints can take several iterations before it occurs.
def __del__(self): # pragma: nocover
self._remove_constraints()
Expand Down
2 changes: 1 addition & 1 deletion iOS/src/toga_iOS/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def __init__(
)

# Construct a NavigationController that provides a navigation bar, and
# is able to maintain a stack of navigable content. This is intialized
# is able to maintain a stack of navigable content. This is initialized
# with a root UIViewController that is the actual content
self.content_controller = UIViewController.alloc().init()
self.controller = UINavigationController.alloc().initWithRootViewController(
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[tool.codespell]
skip = ".git,*.pdf,*.svg"
# the way to make case sensitive skips of words etc
ignore-regex = "\bNd\b"
ignore-words-list = "te,crate"
Comment on lines +4 to +5
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be replaced with inline comments once codespell-project/codespell#1212 is fixed, but it looks like a global ignore is the best option at the moment.


# The coverage settings in this file only control `coverage report`. `coverage run` and
# `coverage combine` are controlled by the pyproject.toml files in each package's
# subdirectory.
Expand Down
4 changes: 2 additions & 2 deletions testbed/tests/widgets/test_label.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def make_lines(n):
await probe.redraw("Label should be resized vertically")
line_height = probe.height

# Label should have a signficant width.
# Label should have a significant width.
assert probe.width > 50

# Empty text should not cause the widget to collapse.
Expand All @@ -57,5 +57,5 @@ def make_lines(n):
(line_height * n) + (line_spacing * (n - 1)),
rel=0.1,
)
# Label should have a signficant width.
# Label should have a significant width.
assert probe.width > 50
2 changes: 1 addition & 1 deletion testbed/tests/widgets/test_selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ async def test_selection_change(widget, probe):
on_change_handler = Mock()
widget.on_change = on_change_handler

# Change the selection programatically
# Change the selection programmatically
assert widget.value == "first"
widget.value = "third"

Expand Down
2 changes: 1 addition & 1 deletion testbed/tests/widgets/test_webview.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ async def widget(on_load):
assert ua.startswith("Mozilla/5.0 (")
break
except AssertionError:
# On Windows, user_agent will return an empty string during intialization.
# On Windows, user_agent will return an empty string during initialization.
if (
toga.platform.current_platform == "windows"
and ua == ""
Expand Down
2 changes: 1 addition & 1 deletion toga/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Backends are also available for `Android <https://pypi.org/project/toga-android>
<https://pypi.org/project/toga-dummy>`__; however, these must be installed manually.

Toga requires **Python 3.8** or newer. It does not support Python 2. Some platforms have
additional prerequisites; see the `Toga plaform guide
additional prerequisites; see the `Toga platform guide
<https://toga.readthedocs.io/en/stable/reference/platforms/index.html>`__ for details.

For more details, see the `Toga project on Github`_.
Expand Down
2 changes: 1 addition & 1 deletion web/src/toga_web/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def dialog_close(event):
# If this is the first time a dialog is being shown, the Shoelace
# autoloader needs to construct the Dialog custom element. We can't
# display the dialog until that element has been fully loaded and
# cosntructed. Only show the dialog when the promise of <sl-dialog>
# constructed. Only show the dialog when the promise of <sl-dialog>
# element construction has been fulfilled.
def show_dialog(promise):
about_dialog.show()
Expand Down