2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00

Fix common spelling mistakes (#4956)

* 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
This commit is contained in:
Matthias Mair
2023-06-03 16:04:52 +02:00
committed by GitHub
parent 5e2bfaa43a
commit 21ed4b2081
161 changed files with 344 additions and 334 deletions

View File

@ -268,7 +268,7 @@ class CategoryParameterList(ListCreateAPI):
class CategoryParameterDetail(RetrieveUpdateDestroyAPI):
"""Detail endpoint fro the PartCategoryParameterTemplate model"""
"""Detail endpoint for the PartCategoryParameterTemplate model"""
queryset = PartCategoryParameterTemplate.objects.all()
serializer_class = part_serializers.CategoryParameterTemplateSerializer
@ -550,7 +550,7 @@ class PartScheduling(RetrieveAPI):
This assumes that the user is responsible for correctly allocating parts.
However, it has the added benefit of side-stepping the various BOM substition options,
However, it has the added benefit of side-stepping the various BOM substitution options,
and just looking at what stock items the user has actually allocated against the Build.
"""
@ -565,10 +565,10 @@ class PartScheduling(RetrieveAPI):
if bom_item.inherited:
# An "inherited" BOM item filters down to variant parts also
childs = bom_item.part.get_descendants(include_self=True)
children = bom_item.part.get_descendants(include_self=True)
builds = Build.objects.filter(
status__in=BuildStatus.ACTIVE_CODES,
part__in=childs,
part__in=children,
)
else:
builds = Build.objects.filter(
@ -591,7 +591,7 @@ class PartScheduling(RetrieveAPI):
# Non-trackable parts are allocated against the build itself
required_quantity = build.quantity * bom_item.quantity
# Grab all allocations against the spefied BomItem
# Grab all allocations against the specified BomItem
allocations = BuildItem.objects.filter(
bom_item=bom_item,
build=build,
@ -1032,7 +1032,7 @@ class PartList(PartMixin, APIDownloadMixin, ListCreateAPI):
return DownloadFile(filedata, filename)
def list(self, request, *args, **kwargs):
"""Overide the 'list' method, as the PartCategory objects are very expensive to serialize!
"""Override the 'list' method, as the PartCategory objects are very expensive to serialize!
So we will serialize them first, and keep them in memory, so that they do not have to be serialized multiple times...
"""
@ -1049,7 +1049,7 @@ class PartList(PartMixin, APIDownloadMixin, ListCreateAPI):
"""
Determine the response type based on the request.
a) For HTTP requests (e.g. via the browseable API) return a DRF response
a) For HTTP requests (e.g. via the browsable API) return a DRF response
b) For AJAX requests, simply return a JSON rendered response.
"""
if page is not None:
@ -1213,7 +1213,7 @@ class PartList(PartMixin, APIDownloadMixin, ListCreateAPI):
def filter_parameteric_data(self, queryset):
"""Filter queryset against part parameters.
Here we can perfom a number of different functions:
Here we can perform a number of different functions:
Ordering Based on Parameter Value:
- Used if the 'ordering' query param points to a parameter
@ -1492,7 +1492,7 @@ class PartParameterDetail(RetrieveUpdateDestroyAPI):
class PartStocktakeFilter(rest_filters.FilterSet):
"""Custom fitler for the PartStocktakeList endpoint"""
"""Custom filter for the PartStocktakeList endpoint"""
class Meta:
"""Metaclass options"""
@ -1702,7 +1702,7 @@ class BomList(BomMixin, ListCreateDestroyAPIView):
"""
Determine the response type based on the request.
a) For HTTP requests (e.g. via the browseable API) return a DRF response
a) For HTTP requests (e.g. via the browsable API) return a DRF response
b) For AJAX requests, simply return a JSON rendered response.
"""
if page is not None:
@ -1748,7 +1748,7 @@ class BomList(BomMixin, ListCreateDestroyAPIView):
There are multiple ways that an assembly can "use" a sub-part:
A) Directly specifying the sub_part in a BomItem field
B) Specifing a "template" part with inherited=True
B) Specifying a "template" part with inherited=True
C) Allowing variant parts to be substituted
D) Allowing direct substitute parts to be specified

View File

@ -53,10 +53,10 @@ def ExportBom(part: Part, fmt='csv', cascade: bool = False, max_levels: int = No
max_levels (int, optional): Levels of items that should be included. None for np sublevels. Defaults to None.
kwargs:
parameter_data (bool, optional): Additonal data that should be added. Defaults to False.
stock_data (bool, optional): Additonal data that should be added. Defaults to False.
supplier_data (bool, optional): Additonal data that should be added. Defaults to False.
manufacturer_data (bool, optional): Additonal data that should be added. Defaults to False.
parameter_data (bool, optional): Additional data that should be added. Defaults to False.
stock_data (bool, optional): Additional data that should be added. Defaults to False.
supplier_data (bool, optional): Additional data that should be added. Defaults to False.
manufacturer_data (bool, optional): Additional data that should be added. Defaults to False.
pricing_data (bool, optional): Include pricing data in exported BOM. Defaults to False
substitute_part_data (bool, optional): Include substitute part numbers in exported BOM. Defaults to False

View File

@ -78,7 +78,7 @@ def annotate_total_stock(reference: str = ''):
- This function calculates the 'total stock' for a given part
- Finds all stock items associated with each part (using the provided filter)
- Aggregates the 'quantity' of each relevent stock item
- Aggregates the 'quantity' of each relevant stock item
Args:
reference: The relationship reference of the part from the current model e.g. 'part'
@ -103,7 +103,7 @@ def annotate_build_order_allocations(reference: str = ''):
- This function calculates the total part quantity allocated to open build orders
- Finds all build order allocations for each part (using the provided filter)
- Aggregates the 'allocated quantity' for each relevent build order allocation item
- Aggregates the 'allocated quantity' for each relevant build order allocation item
Args:
reference: The relationship reference of the part from the current model
@ -128,7 +128,7 @@ def annotate_sales_order_allocations(reference: str = ''):
- This function calculates the total part quantity allocated to open sales orders"
- Finds all sales order allocations for each part (using the provided filter)
- Aggregates the 'allocated quantity' for each relevent sales order allocation item
- Aggregates the 'allocated quantity' for each relevant sales order allocation item
Args:
reference: The relationship reference of the part from the current model

View File

@ -76,7 +76,7 @@
pk: 7
fields:
name: Mechanical
description: Mechanical componenets
description: Mechanical components
default_location: null
level: 0
tree_id: 2

View File

@ -54,7 +54,7 @@ class Migration(migrations.Migration):
('description', models.CharField(help_text='Part description', max_length=250)),
('keywords', models.CharField(blank=True, help_text='Part keywords to improve visibility in search results', max_length=250)),
('IPN', models.CharField(blank=True, help_text='Internal Part Number', max_length=100)),
('URL', models.URLField(blank=True, help_text='Link to extenal URL')),
('URL', models.URLField(blank=True, help_text='Link to external URL')),
('image', models.ImageField(blank=True, max_length=255, null=True, upload_to=part.models.rename_part_image)),
('minimum_stock', models.PositiveIntegerField(default=0, help_text='Minimum allowed stock level', validators=[django.core.validators.MinValueValidator(0)])),
('units', models.CharField(blank=True, default='pcs', help_text='Stock keeping units for this part', max_length=20)),

View File

@ -14,6 +14,6 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='part',
name='URL',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to extenal URL'),
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL'),
),
]

View File

@ -25,7 +25,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='part',
name='link',
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to extenal URL', null=True),
field=InvenTree.fields.InvenTreeURLField(blank=True, help_text='Link to external URL', null=True),
),
migrations.AlterField(
model_name='part',

View File

@ -1543,7 +1543,7 @@ class Part(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, MPTTModel)
A) This part may be directly specified in a BomItem instance
B) This part may be a *variant* of a part which is directly specified in a BomItem instance
C) This part may be a *substitute* for a part which is directly specifed in a BomItem instance
C) This part may be a *substitute* for a part which is directly specified in a BomItem instance
So we construct a query for each case, and combine them...
"""
@ -2173,7 +2173,7 @@ class Part(InvenTreeBarcodeMixin, InvenTreeNotesMixin, MetadataMixin, MPTTModel)
return self.parameters.order_by('template__name')
def parameters_map(self):
"""Return a map (dict) of parameter values assocaited with this Part instance, of the form.
"""Return a map (dict) of parameter values associated with this Part instance, of the form.
Example:
{
@ -3198,7 +3198,7 @@ class PartTestTemplate(MetadataMixin, models.Model):
"""A PartTestTemplate defines a 'template' for a test which is required to be run against a StockItem (an instance of the Part).
The test template applies "recursively" to part variants, allowing tests to be
defined in a heirarchy.
defined in a hierarchy.
Test names are simply strings, rather than enforcing any sort of structure or pattern.
It is up to the user to determine what tests are defined (and how they are run).

View File

@ -189,7 +189,7 @@ def perform_stocktake(target: part.models.Part, user: User, note: str = '', comm
total_cost_max += pp
has_pricing = True
except MissingRate:
logger.warning(f"MissingRate exception occured converting {entry.purchase_price} to {base_currency}")
logger.warning(f"MissingRate exception occurred converting {entry.purchase_price} to {base_currency}")
if not has_pricing:
# Fall back to the part pricing data

View File

@ -295,7 +295,7 @@ def inventree_github_url(*args, **kwargs):
@register.simple_tag()
def inventree_docs_url(*args, **kwargs):
"""Return URL for InvenTree documenation site."""
"""Return URL for InvenTree documentation site."""
tag = version.inventreeDocsVersion()
return f"https://docs.inventree.org/en/{tag}"
@ -605,7 +605,7 @@ else: # pragma: no cover
bits = token.split_contents()
loc_name = settings.STATICFILES_I18_PREFIX
# change path to called ressource
# change path to called resource
bits[1] = f"'{loc_name}/{{lng}}.{bits[1][1:-1]}'"
token.contents = ' '.join(bits)

View File

@ -1078,10 +1078,10 @@ class PartAPITest(PartAPITestBase):
'export': 'csv',
},
expected_fn='InvenTree_Parts.csv',
) as fo:
) as file:
data = self.process_csv(
fo,
file,
excluded_cols=excluded_cols,
required_cols=required_cols,
required_rows=Part.objects.count(),

View File

@ -141,7 +141,7 @@ class BomItemTest(TestCase):
def test_substitutes(self):
"""Tests for BOM item substitutes."""
# We will make some subtitute parts for the "orphan" part
# We will make some substitute parts for the "orphan" part
bom_item = BomItem.objects.get(
part=self.bob,
sub_part=self.orphan

View File

@ -49,14 +49,14 @@ class CategoryTest(TestCase):
self.assertEqual(len(self.electronics.children.all()), 3)
self.assertEqual(len(self.mechanical.children.all()), 1)
def test_unique_childs(self):
def test_unique_children(self):
"""Test the 'unique_children' functionality."""
childs = [item.pk for item in self.electronics.getUniqueChildren()]
children = [item.pk for item in self.electronics.getUniqueChildren()]
self.assertIn(self.transceivers.id, childs)
self.assertIn(self.ic.id, childs)
self.assertIn(self.transceivers.id, children)
self.assertIn(self.ic.id, children)
self.assertNotIn(self.fasteners.id, childs)
self.assertNotIn(self.fasteners.id, children)
def test_unique_parents(self):
"""Test the 'unique_parents' functionality."""
@ -168,7 +168,7 @@ class CategoryTest(TestCase):
parts_parameters = self.fasteners.get_parts_parameters(prefetch=fasteners)
part_infos = ['pk', 'name', 'description']
for part_parameter in parts_parameters:
# Remove part informations
# Remove part information
for item in part_infos:
part_parameter.pop(item)
self.assertEqual(len(part_parameter), 1)

View File

@ -55,7 +55,7 @@ class TestBomItemMigrations(MigratorTestCase):
migrate_to = ('part', unit_test.getNewestMigrationFile('part'))
def prepare(self):
"""Create intial dataset"""
"""Create initial dataset"""
Part = self.old_state.apps.get_model('part', 'part')
BomItem = self.old_state.apps.get_model('part', 'bomitem')

View File

@ -515,7 +515,7 @@ class PartSettingsTest(InvenTreeTestCase):
Part.objects.create(name='zyx', description='A part', IPN='UNIQUE')
# However, *blank* / empty IPN values should be allowed, even if duplicates are not
# Note that leading / trailling whitespace characters are trimmed, too
# Note that leading / trailing whitespace characters are trimmed, too
Part.objects.create(name='abc', revision='1', description='A part', IPN=None)
Part.objects.create(name='abc', revision='2', description='A part', IPN='')
Part.objects.create(name='abc', revision='3', description='A part', IPN=None)

View File

@ -233,7 +233,7 @@ class PartImport(FileManagementFormView):
image=part_data.get('image', None),
)
# check if theres a category assigned, if not skip this part or else bad things happen
# check if there's a category assigned, if not skip this part or else bad things happen
if not optional_matches['Category']:
import_error.append(_("Can't import part {name} because there is no category assigned").format(name=new_part.name))
continue
@ -260,7 +260,7 @@ class PartImport(FileManagementFormView):
messages.success(self.request, alert)
if import_error:
error_text = '\n'.join([f'<li><strong>{import_error.count(a)}</strong>: {a}</li>' for a in set(import_error)])
messages.error(self.request, f"<strong>{_('Some errors occured:')}</strong><br><ul>{error_text}</ul>")
messages.error(self.request, f"<strong>{_('Some errors occurred:')}</strong><br><ul>{error_text}</ul>")
return HttpResponseRedirect(reverse('part-index'))