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 (config, workflow) and use it to fix found typos (and some manully) #8173

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Codespell configuration is within pyproject.toml
---
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: Codespell
uses: codespell-project/actions-codespell@v2
82 changes: 41 additions & 41 deletions CHANGELOG.rst

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion changes/6790.misc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Activites extracted into `activity` plugin. As result, activity tabs from the
Activities extracted into `activity` plugin. As result, activity tabs from the
dataset, group, organization and user sections are not shown by default; new
activities are not recorded; all the API actions related to activity are not
available.
Expand Down
2 changes: 1 addition & 1 deletion changes/6817.bugfix
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Fix theme settings. Options which were used to specify a CSS file
with a base theme are replaced. Use altenatives below in order
with a base theme are replaced. Use alternatives below in order
to specify **asset** with a base theme for application:

* `ckan.main_css` replaced by `ckan.theme`
Expand Down
2 changes: 1 addition & 1 deletion changes/7169.bugfix
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fix activity stream icon on Boostrap 5. Migrate activity CSS classes to the extension folder.
Fix activity stream icon on Bootstrap 5. Migrate activity CSS classes to the extension folder.
2 changes: 1 addition & 1 deletion changes/7193.misc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fix color contrast in dashboard buttons for web accesibility
Fix color contrast in dashboard buttons for web accessibility
2 changes: 1 addition & 1 deletion changes/7199.misc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Fix color contrast of delete button in user edit page for web accesibility
Fix color contrast of delete button in user edit page for web accessibility
2 changes: 1 addition & 1 deletion changes/7257.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Before, such values were just wrapped into a list, i.e: ``[value]``.
:widths: 40 30 30
:header-rows: 1

* - Expresion
* - Expression
- Before
- After
* - ``aslist([1,2])``
Expand Down
2 changes: 1 addition & 1 deletion changes/7402.feature
Original file line number Diff line number Diff line change
@@ -1 +1 @@
update documenatation for CKAN SHELL command.
update documentation for CKAN SHELL command.
2 changes: 1 addition & 1 deletion changes/7637.removal
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Remove Boostrap 3 support.
Remove Bootstrap 3 support.
2 changes: 1 addition & 1 deletion changes/7638.bugfix
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Plugins randomly change their order during test session and somethimes they
Plugins randomly change their order during test session and sometimes they
work even without ``with_plugins`` fixture.
6 changes: 3 additions & 3 deletions ckan/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def get_group_or_org_admin_ids(group_id: Optional[str]) -> list[str]:
.filter(model.Member.state == 'active') \
.filter(model.Member.capacity == 'admin')

# type_ignore_reason: all stored memerships have table_id
# type_ignore_reason: all stored memberships have table_id
return [a.table_id for a in q]


Expand Down Expand Up @@ -519,11 +519,11 @@ def user_is_collaborator_on_dataset(
def check_config_permission(permission: str) -> Union[list[str], bool]:
'''Returns the configuration value for the provided permission

Permission is a string indentifying the auth permission (eg
Permission is a string identifying the auth permission (eg
`anon_create_dataset`), optionally prefixed with `ckan.auth.`.

The possible values for `permission` are the keys of
CONFIG_PERMISSIONS_DEFAULTS. These can be overriden in the config file
CONFIG_PERMISSIONS_DEFAULTS. These can be overridden in the config file
by prefixing them with `ckan.auth.`.

Returns the permission value, generally True or False, except on
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _get_users_with_invalid_image(mimetypes: List[str]) -> List[model.User]:

@clean.command("users", short_help="Clean users containing invalid images.")
@click.option(
"-f", "--force", is_flag=True, help="Do not ask for comfirmation."
"-f", "--force", is_flag=True, help="Do not ask for confirmation."
)
def users(force: bool):
"""Removes users with invalid images from the database.
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def _add_external_commands(ctx: click.Context):


def _command_with_ckan_meta(cmd: click.Command, name: str, type_: str):
"""Mark command as one retrived from CKAN extension.
"""Mark command as one retrieved from CKAN extension.

This information is used when CLI help text is generated.
"""
Expand Down
4 changes: 2 additions & 2 deletions ckan/cli/search_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_orphans() -> list[str]:

@search_index.command(
name=u'list-orphans',
short_help=u'Lists any non-existant packages in the search index'
short_help=u'Lists any non-existent packages in the search index'
)
def list_orphans_command():
orphaned_package_ids = get_orphans()
Expand All @@ -119,7 +119,7 @@ def list_orphans_command():

@search_index.command(
name=u'clear-orphans',
short_help=u'Clear any non-existant packages in the search index'
short_help=u'Clear any non-existent packages in the search index'
)
@click.option(u'-v', u'--verbose', is_flag=True)
def clear_orphans(verbose: bool = False):
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def mangle():
u'''This will mangle the zh_TW translations for translation coverage
testing.

NOTE: This will destroy the current translations fot zh_TW
NOTE: This will destroy the current translations for zh_TW
'''
i18n_path = get_i18n_path()
pot_path = os.path.join(i18n_path, u'ckan.pot')
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def add_user(ctx: click.Context, username: str, args: list[str]):
u'user': site_user['name'],
}
flask_app = ctx.meta['flask_app']
# Current user is tested agains sysadmin role during model
# Current user is tested against sysadmin role during model
# dictization, thus we need request context
with flask_app.test_request_context():
user_dict = logic.get_action(u'user_create')(context, data_dict)
Expand Down
2 changes: 1 addition & 1 deletion ckan/cli/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def clean(ctx: click.Context, yes: bool):

def _get_view_plugins(view_plugin_types: list[str],
get_datastore_views: bool = False):
"""Returns the view plugins that were succesfully loaded
"""Returns the view plugins that were successfully loaded

Views are provided as a list of ``view_plugin_types``. If no types
are provided, the default views defined in the
Expand Down
2 changes: 1 addition & 1 deletion ckan/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# but at the same time making it easy to change for example the json lib
# used.
#
# NOTE: This file is specificaly created for
# NOTE: This file is specifically created for
# from ckan.common import x, y, z to be allowed
from __future__ import annotations

Expand Down
2 changes: 1 addition & 1 deletion ckan/config/declaration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def setup(self):
self._seal()

def make_safe(self, config: "CKANConfig"):
"""Load defaul values for missing options.
"""Load default values for missing options.
"""

for key in self.iter_options(exclude=Flag.not_safe()):
Expand Down
2 changes: 1 addition & 1 deletion ckan/config/declaration/load.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
"""This module defines the ways to fill config declaration with difinitions
"""This module defines the ways to fill config declaration with definitions
from different sources.

New loaders can be defined in the following manner:
Expand Down
14 changes: 7 additions & 7 deletions ckan/config/declaration/option.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Flag(enum.Flag):


ignored: this option is ignored by CKAN(not used or unconditionally
overriden)
overridden)

experimental: this option is not stabilized and can change in
future. Mainly exist for extension developers, as only stable features are
Expand Down Expand Up @@ -61,13 +61,13 @@ class Flag(enum.Flag):
domain. While it's similar to `placeholder` attribute of the
:py:class:`~ckan.config.declaration.option.Option`, their goals are
different.
Option.placeholer:
Option.placeholder:
- shows an example of expectend value
- is ignored when config option is **missing** from the config file
- shown as a default value in the config file generated from template. For
example, `Option<key=a, placeholder=b, commented=False>` is added to the
config file as `a = b`. After this, `config.get('a')` returns `b`,
because it's explicitely written in the config file.
because it's explicitly written in the config file.
Flag.commented:
- Marks option as commented by default
- Does not changes behavior of `Option.default` and `Option.placeholder`.
Expand All @@ -83,7 +83,7 @@ class Flag(enum.Flag):
reserved_*(01-10): these flags are added for extension developers. CKAN
doesn't treat them specially, neither includes them in groups, like
`not_safe`/`not_iterable`. These flags are completely ignored by CKAN. If
your extension enchances the behavior of config options using some sort of
your extension enhances the behavior of config options using some sort of
boolean flags - use reserved markers. Always rely on a config option that
controls, which reserved marker to use, in order to avoid conflicts with
other extensions. Example:
Expand Down Expand Up @@ -153,7 +153,7 @@ class Annotation(SectionMixin, str):
"""Details that are not attached to any option.

Mainly serves documentation purposes. Can be used for creating section
separators or blocks of text with the recomendations, that are not
separators or blocks of text with the recommendations, that are not
connected to any particular option and rather describle the whole section.

"""
Expand Down Expand Up @@ -223,7 +223,7 @@ def str_value(self, value: T | object = _sentinel) -> str:

If more sophisticated logic cannot be avoided, consider creating a
subclass of :py:class:`~ckan.config.declaration.option.Option` with
custom `str_value` implemetation and declaring the option using
custom `str_value` implementation and declaring the option using
`declare_option` method of
:py:class:`~ckan.config.declaration.Declaration`.

Expand Down Expand Up @@ -389,7 +389,7 @@ def _validators_from_string(s: str) -> list[Validator]:
try:
parsed_args = ast.literal_eval(args)
if not isinstance(parsed_args, tuple) or not parsed_args:
# it's a signle argument. `not parsed_args` means that this
# it's a single argument. `not parsed_args` means that this
# single argument is an empty tuple,
# for example: "default(())"

Expand Down
2 changes: 1 addition & 1 deletion ckan/config/middleware/common_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class RootPathMiddleware(object):
'''
Prevents the SCRIPT_NAME server variable conflicting with the ckan.root_url
config. The routes package uses the SCRIPT_NAME variable and appends to the
path and ckan addes the root url causing a duplication of the root path.
path and ckan adds the root url causing a duplication of the root path.
This is a middleware to ensure that even redirects use this logic.
'''
def __init__(self, app: CKANApp):
Expand Down
2 changes: 1 addition & 1 deletion ckan/config/middleware/flask_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ class CKANFlask(MultiStaticFlask):


def _register_plugins_blueprints(app: CKANApp):
""" Resgister all blueprints defined in plugins by IBlueprint
""" Register all blueprints defined in plugins by IBlueprint
"""
for plugin in PluginImplementations(IBlueprint):
plugin_blueprints = plugin.get_blueprint()
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/app_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
}


# A place to store the origional config options of we override them
# A place to store the original config options of we override them
_CONFIG_CACHE: dict[str, Any] = {}

def set_theme(asset: str) -> None:
Expand Down
6 changes: 3 additions & 3 deletions ckan/lib/dictization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def get_unique_constraints(table: Table, context: Context) -> list[list[str]]:

list_of_constraints: list[list[str]] = []

for contraint in table.constraints:
if isinstance(contraint, sqlalchemy.UniqueConstraint):
columns = [column.name for column in contraint.columns]
for constraint in table.constraints:
Copy link
Contributor

Choose a reason for hiding this comment

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

local variable change -- looks safe

if isinstance(constraint, sqlalchemy.UniqueConstraint):
columns = [column.name for column in constraint.columns]
list_of_constraints.append(columns)

return list_of_constraints
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/dictization/model_dictize.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def get_packages_for_this_group(group_: model.Group,
image_url = result_dict.get('image_url')
result_dict['image_display_url'] = image_url
if image_url and not image_url.startswith('http'):
#munge here should not have an effect only doing it incase
#munge here should not have an effect only doing it in case
#of potential vulnerability of dodgy api input
image_url = munge.munge_filename_legacy(image_url)
result_dict['image_display_url'] = h.url_for_static(
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def localised_nice_date(datetime_: datetime.datetime,
:type format: str


:rtype: sting
:rtype: string
'''
if datetime_.tzinfo is None:
datetime_ = datetime_.replace(tzinfo=pytz.utc)
Expand Down
12 changes: 6 additions & 6 deletions ckan/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,10 @@ def humanize_entity_type(entity_type: str, object_type: str,
`my label`: "My [object]s" tab in dashboard
`name placeholder`: "<[object]>" section of URL preview on object form
`no any objects`: No objects created yet
`no associated label`: no gorups for dataset
`no associated label`: no groups for dataset
`no description`: object has no description
`no label`: package with no organization
`page title`: "Title - [objec]s - CKAN" section of page title
`page title`: "Title - [object]s - CKAN" section of page title
`save label`: "Save [object]" button
`search placeholder`: "Search [object]s..." placeholder
`update label`: "Update [object]" button
Expand Down Expand Up @@ -1080,7 +1080,7 @@ def get_facet_items_dict(
'''Return the list of unselected facet items for the given facet, sorted
by count.

Returns the list of unselected facet contraints or facet items (e.g. tag
Returns the list of unselected facet constraints or facet items (e.g. tag
names like "russian" or "tolstoy") for the given search facet (e.g.
"tags"), sorted by facet item count (i.e. the number of search results that
match each facet item).
Expand Down Expand Up @@ -1755,7 +1755,7 @@ def snippet(template_name: str, **kw: Any) -> str:
@core_helper
def convert_to_dict(object_type: str, objs: list[Any]) -> list[dict[str, Any]]:
''' This is a helper function for converting lists of objects into
lists of dicts. It is for backwards compatability only. '''
lists of dicts. It is for backwards compatibility only. '''

import ckan.lib.dictization.model_dictize as md
converters = {'package': md.package_dictize}
Expand Down Expand Up @@ -1862,7 +1862,7 @@ def add_url_param(alternative_url: Optional[str] = None,
:py:func:`~ckan.lib.helpers.url_for` controller & action default to the
current ones

This can be overriden providing an alternative_url, which will be used
This can be overridden providing an alternative_url, which will be used
instead.
'''

Expand Down Expand Up @@ -1900,7 +1900,7 @@ def remove_url_param(key: Union[list[str], str],
via :py:func:`~ckan.lib.helpers.url_for`
controller & action default to the current ones

This can be overriden providing an alternative_url, which will be used
This can be overridden providing an alternative_url, which will be used
instead.

'''
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/jinja_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def parse(self, parser: Any) -> Any:

class CkanExtend(ext.Extension):
''' Custom {% ckan_extends <template> %} tag that allows templates
to inherit from the ckan template futher down the template search path
to inherit from the ckan template further down the template search path
if no template provided we assume the same template name. '''

tags = set(['ckan_extends'])
Expand Down
2 changes: 1 addition & 1 deletion ckan/lib/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def execute_job(self, job: Job, *args: Any, **kwargs: Any) -> None:
# https://github.com/ckan/ckan/issues/3365
#
# Note that this rolls back any non-committed changes in the session.
# Both `Session` and `engine` automatically re-initialize themselve
# Both `Session` and `engine` automatically re-initialize themselves
# when they are used the next time.
log.debug(u'Disposing database engine before fork')
meta.Session.remove()
Expand Down
6 changes: 3 additions & 3 deletions ckan/lib/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def __init__(self,
# We subclassed "list" so we need to call its init() method
# and fill the new list with the items to be displayed on the page.
# We use list() so that the items on the current page are retrieved
# only once. Otherwise it would run the actual SQL query everytime
# only once. Otherwise it would run the actual SQL query every time
# .items would be accessed.
if presliced_list:
self.items = self.collection
Expand Down Expand Up @@ -410,7 +410,7 @@ def pager(self,
Default: { 'class':'pager_dotdot' }

onclick (optional)
This paramter is a string containing optional Javascript
This parameter is a string containing optional Javascript
code that will be used as the 'onclick' action of each
pager link. It can be used to enhance your pager with
AJAX actions loading another page into a DOM object.
Expand Down Expand Up @@ -554,7 +554,7 @@ def _range(self, regexp_match: Match[str]):
nav_items.append(text)

for thispage in range(leftmost_page, rightmost_page + 1):
# Hilight the current page number and do not use a link
# Highlight the current page number and do not use a link
if thispage == self.page:
text = u"%s" % (thispage,)
# Wrap in a SPAN tag if nolink_attr is set
Expand Down