Skip to content

Commit

Permalink
Fix common spelling mistakes (inventree#4956)
Browse files Browse the repository at this point in the history
* add codespell

* first fixes

* doc fixes

* fix docstrings and comments

* functional changes

* docstrings again

* and docs again

* rename args

* add ignore

* use pre-commit for filtering instead

* ups

* fix typo in filter
  • Loading branch information
matmair authored Jun 3, 2023
1 parent 5e2bfaa commit 21ed4b2
Show file tree
Hide file tree
Showing 161 changed files with 344 additions and 334 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ body:
id: repro
attributes:
label: Body of the issue
description: Please provide one distinct thing to fix or a clearly defined enhancment
description: Please provide one distinct thing to fix or a clearly defined enhancement
validations:
required: true
4 changes: 2 additions & 2 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'Setup Enviroment'
description: 'Setup the enviroment for general InvenTree tests'
description: 'Setup the environment for general InvenTree tests'
author: 'InvenTree'
inputs:
python:
Expand Down Expand Up @@ -62,7 +62,7 @@ runs:
with:
node-version: ${{ env.node_version }}
cache: 'npm'
- name: Intall npm packages
- name: Install npm packages
if: ${{ inputs.npm == 'true' }}
shell: bash
run: npm install
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/qc_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
dev-install: true
Expand All @@ -64,7 +64,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
npm: true
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
apt-dependency: gettext poppler-utils
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
install: true
Expand All @@ -191,7 +191,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
apt-dependency: gettext poppler-utils
Expand Down Expand Up @@ -241,7 +241,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
apt-dependency: gettext poppler-utils libpq-dev
Expand Down Expand Up @@ -286,7 +286,7 @@ jobs:

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
- name: Enviroment Setup
- name: Environment Setup
uses: ./.github/actions/setup
with:
apt-dependency: gettext poppler-utils libmysqlclient-dev
Expand Down
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,13 @@ repos:
rev: v1.29.0
hooks:
- id: djlint-django
- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
hooks:
- id: codespell
exclude: >
(?x)^(
docs/docs/stylesheets/.*|
docs/docs/javascripts/.*|
docs/docs/webfonts/.*
)$
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Hi there, thank you for your intrest in contributing!
Hi there, thank you for your interest in contributing!
Please read the contribution guidelines below, before submitting your first pull request to the InvenTree codebase.

## Quickstart
Expand Down Expand Up @@ -50,7 +50,7 @@ The HEAD of the "main" or "master" branch of InvenTree represents the current "l
- All feature branches are merged into master
- All bug fixes are merged into master

**No pushing to master:** New featues must be submitted as a pull request from a separate branch (one branch per feature).
**No pushing to master:** New features must be submitted as a pull request from a separate branch (one branch per feature).

### Feature Branches

Expand All @@ -70,7 +70,7 @@ The HEAD of the "stable" branch represents the latest stable release code.
#### Release Candidate Branches

- Release candidate branches are made from master, and merged into stable.
- RC branches are targetted at a major/minor version e.g. "0.5"
- RC branches are targeted at a major/minor version e.g. "0.5"
- When a release candidate branch is merged into *stable*, the release is tagged

#### Bugfix Branches
Expand Down Expand Up @@ -137,7 +137,7 @@ invoke test --runtest order

## Code Style

Sumbitted Python code is automatically checked against PEP style guidelines. Locally you can run `invoke style` to ensure the style checks will pass, before submitting the PR.
Submitted Python code is automatically checked against PEP style guidelines. Locally you can run `invoke style` to ensure the style checks will pass, before submitting the PR.
Please write docstrings for each function and class - we follow the [google doc-style](https://google.github.io/styleguide/pyguide.html#38-comments-and-docstrings) for python. Docstrings for general javascript code is encouraged! Docstyles are checked by `invoke style`.

### Django templates
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NotFoundView(AjaxView):
permission_classes = [permissions.AllowAny]

def get(self, request, *args, **kwargs):
"""Proces an `not found` event on the API."""
"""Process an `not found` event on the API."""
data = {
'details': _('API endpoint not found'),
'url': request.build_absolute_uri(),
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/api_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@
- Allow BOM List API endpoint to be filtered by "on_order" parameter
v63 -> 2022-07-06 : https://github.com/inventree/InvenTree/pull/3301
- Allow BOM List API endpoint to be filtered by "available_stock" paramater
- Allow BOM List API endpoint to be filtered by "available_stock" parameter
v62 -> 2022-07-05 : https://github.com/inventree/InvenTree/pull/3296
- Allows search on BOM List API endpoint
Expand Down
6 changes: 3 additions & 3 deletions InvenTree/InvenTree/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def ready(self):
- Checking if migrations should be run
- Cleaning up tasks
- Starting regular tasks
- Updateing exchange rates
- Collecting notification mehods
- Updating exchange rates
- Collecting notification methods
- Adding users set in the current environment
"""
if canAppAccessDatabase() or settings.TESTING_ENV:
Expand Down Expand Up @@ -84,7 +84,7 @@ def start_background_tasks(self):
minutes=task.minutes,
)

# Put at least one task onto the backround worker stack,
# Put at least one task onto the background worker stack,
# which will be processed as soon as the worker comes online
InvenTree.tasks.offload_task(
InvenTree.tasks.heartbeat,
Expand Down
4 changes: 2 additions & 2 deletions InvenTree/InvenTree/ci_render_js.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Pull rendered copies of the templated.
Only used for testing the js files! - This file is omited from coverage.
Only used for testing the js files! - This file is omitted from coverage.
"""

import os # pragma: no cover
Expand All @@ -17,7 +17,7 @@ class RenderJavascriptFiles(InvenTreeTestCase): # pragma: no cover
"""

def download_file(self, filename, prefix):
"""Function to `download`(copy) a file to a temporay firectory."""
"""Function to `download`(copy) a file to a temporary firectory."""
url = os.path.join(prefix, filename)

response = self.client.get(url)
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def set_metadata(source: str):


def get_boolean_setting(env_var=None, config_key=None, default_value=False):
"""Helper function for retreiving a boolean configuration setting"""
"""Helper function for retrieving a boolean configuration setting"""

return is_true(get_setting(env_var, config_key, default_value))

Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def log_error(path):

kind, info, data = sys.exc_info()

# Check if the eror is on the ignore list
# Check if the error is on the ignore list
if kind in settings.IGNORED_ERRORS:
return

Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def get_search_fields(self, view, request):
"""Return a set of search fields for the request, adjusted based on request params.
The following query params are available to 'augment' the search (in decreasing order of priority)
- search_regex: If True, search is perfomed on 'regex' comparison
- search_regex: If True, search is performed on 'regex' comparison
"""

regex = InvenTree.helpers.str2bool(request.query_params.get('search_regex', False))
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def construct_format_regex(fmt_string: str) -> str:
# Add a named capture group for the format entry
if name:

# Check if integer values are requried
# Check if integer values are required
if format.endswith('d'):
chr = '\d'
else:
Expand Down
6 changes: 3 additions & 3 deletions InvenTree/InvenTree/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class RegistratonMixin:
def is_open_for_signup(self, request, *args, **kwargs):
"""Check if signup is enabled in settings.
Configure the class variable `REGISTRATION_SETTING` to set which setting should be used, defualt: `LOGIN_ENABLE_REG`.
Configure the class variable `REGISTRATION_SETTING` to set which setting should be used, default: `LOGIN_ENABLE_REG`.
"""
if settings.EMAIL_HOST and (InvenTreeSetting.get_setting('LOGIN_ENABLE_REG') or InvenTreeSetting.get_setting('LOGIN_ENABLE_SSO_REG')):
return super().is_open_for_signup(request, *args, **kwargs)
Expand Down Expand Up @@ -253,7 +253,7 @@ def save_user(self, request, user, form, commit=True):
group = Group.objects.get(id=start_group)
user.groups.add(group)
except Group.DoesNotExist:
logger.error('The setting `SIGNUP_GROUP` contains an non existant group', start_group)
logger.error('The setting `SIGNUP_GROUP` contains an non existent group', start_group)
user.save()
return user

Expand All @@ -276,7 +276,7 @@ def send_mail(self, template_prefix, email, context):
try:
result = super().send_mail(template_prefix, email, context)
except Exception:
# An exception ocurred while attempting to send email
# An exception occurred while attempting to send email
# Log it (for admin users) and return silently
log_error('account email')
result = False
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def add_serial(serial):

serial = serial.strip()

# Ignore blank / emtpy serials
# Ignore blank / empty serials
if len(serial) == 0:
return

Expand Down
8 changes: 4 additions & 4 deletions InvenTree/InvenTree/helpers_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def construct_absolute_url(*arg, **kwargs):
This is useful when (for example) sending an email to a user with a link
to something in the InvenTree web framework.
A URL is constructed in the following order:
1. If setings.SITE_URL is set (e.g. in the Django settings), use that
1. If settings.SITE_URL is set (e.g. in the Django settings), use that
2. If the InvenTree setting INVENTREE_BASE_URL is set, use that
3. Otherwise, use the current request URL (if available)
"""
Expand Down Expand Up @@ -150,7 +150,7 @@ def download_image_from_url(remote_url, timeout=2.5):
raise ValueError(_("Image size is too large"))

# Download the file, ensuring we do not exceed the reported size
fo = io.BytesIO()
file = io.BytesIO()

dl_size = 0
chunk_size = 64 * 1024
Expand All @@ -161,15 +161,15 @@ def download_image_from_url(remote_url, timeout=2.5):
if dl_size > max_size:
raise ValueError(_("Image download exceeded maximum size"))

fo.write(chunk)
file.write(chunk)

if dl_size == 0:
raise ValueError(_("Remote server returned empty response"))

# Now, attempt to convert the downloaded data to a valid image file
# img.verify() will throw an exception if the image is not valid
try:
img = Image.open(fo).convert()
img = Image.open(file).convert()
img.verify()
except Exception:
raise TypeError(_("Supplied URL is not a valid image file"))
Expand Down
4 changes: 2 additions & 2 deletions InvenTree/InvenTree/management/commands/prerender.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def render_file(file_name, source, target, locales, ctx):

with open(target_file, 'w') as localised_file:
with lang_over(locale):
renderd = render_to_string(os.path.join(source, file_name), ctx)
localised_file.write(renderd)
rendered = render_to_string(os.path.join(source, file_name), ctx)
localised_file.write(rendered)


class Command(BaseCommand):
Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/management/commands/wait_for_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ def handle(self, *args, **kwargs):
self.stdout.write("Database configuration is not usable")

if connected:
self.stdout.write("Database connection sucessful!")
self.stdout.write("Database connection successful!")
4 changes: 2 additions & 2 deletions InvenTree/InvenTree/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class InvenTreeMetadata(SimpleMetadata):
"""

def determine_metadata(self, request, view):
"""Overwrite the metadata to adapt to hte request user."""
"""Overwrite the metadata to adapt to the request user."""
self.request = request
self.view = view

metadata = super().determine_metadata(request, view)

"""
Custom context information to pass through to the OPTIONS endpoint,
if the "context=True" is supplied to the OPTIONS requst
if the "context=True" is supplied to the OPTIONS request
Serializer class can supply context data by defining a get_context_data() method (no arguments)
"""
Expand Down
4 changes: 2 additions & 2 deletions InvenTree/InvenTree/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ class InvenTreeExceptionProcessor(ExceptionProcessor):
"""Custom exception processor that respects blocked errors."""

def process_exception(self, request, exception):
"""Check if kind is ignored before procesing."""
"""Check if kind is ignored before processing."""
kind, info, data = sys.exc_info()

# Check if the eror is on the ignore list
# Check if the error is on the ignore list
if kind in settings.IGNORED_ERRORS:
return

Expand Down
2 changes: 1 addition & 1 deletion InvenTree/InvenTree/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class CreateAPI(CleanMixin, generics.CreateAPIView):


class RetrieveAPI(generics.RetrieveAPIView):
"""View for retreive API."""
"""View for retrieve API."""
pass


Expand Down
6 changes: 3 additions & 3 deletions InvenTree/InvenTree/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class DataImportMixin(object):
Models which implement this mixin should provide information on the fields available for import
"""

# Define a map of fields avaialble for import
# Define a map of fields available for import
IMPORT_FIELDS = {}

@classmethod
Expand Down Expand Up @@ -712,12 +712,12 @@ def getAcceptableParents(self):
available = contents.get_all_objects_for_this_type()

# List of child IDs
childs = self.getUniqueChildren()
children = self.getUniqueChildren()

acceptable = [None]

for a in available:
if a.id not in childs:
if a.id not in children:
acceptable.append(a)

return acceptable
Expand Down
Loading

0 comments on commit 21ed4b2

Please sign in to comment.