2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-03 04:00:57 +00:00

fix a number of A002 cases

This commit is contained in:
Matthias Mair
2024-08-20 00:41:06 +02:00
parent 377a416cbc
commit 78e9de2179
6 changed files with 21 additions and 20 deletions
docs
pyproject.toml
src/backend/InvenTree
InvenTree
common
report
templatetags

@ -200,12 +200,13 @@ def define_env(env):
return assets return assets
@env.macro @env.macro
def includefile(filename: str, title: str, format: str = ''): def includefile(filename: str, title: str, fmt: str = ''):
"""Include a file in the documentation, in a 'collapse' block. """Include a file in the documentation, in a 'collapse' block.
Arguments: Arguments:
- filename: The name of the file to include (relative to the top-level directory) - filename: The name of the file to include (relative to the top-level directory)
- title: - title:
- fmt:
""" """
here = os.path.dirname(__file__) here = os.path.dirname(__file__)
path = os.path.join(here, '..', filename) path = os.path.join(here, '..', filename)
@ -218,7 +219,7 @@ def define_env(env):
content = f.read() content = f.read()
data = f'??? abstract "{title}"\n\n' data = f'??? abstract "{title}"\n\n'
data += f' ```{format}\n' data += f' ```{fmt}\n'
data += textwrap.indent(content, ' ') data += textwrap.indent(content, ' ')
data += '\n\n' data += '\n\n'
data += ' ```\n\n' data += ' ```\n\n'
@ -233,7 +234,7 @@ def define_env(env):
'src', 'backend', 'InvenTree', 'report', 'templates', filename 'src', 'backend', 'InvenTree', 'report', 'templates', filename
) )
return includefile(fn, f'Template: {base}', format='html') return includefile(fn, f'Template: {base}', fmt='html')
@env.macro @env.macro
def rendersetting(setting: dict): def rendersetting(setting: dict):

@ -59,7 +59,7 @@ ignore = [
"B904", "B904",
# Remove fast # Remove fast
"A001", "A002","A003","B018" "A001", "A002", "B018"
] ]
[tool.ruff.lint.pydocstyle] [tool.ruff.lint.pydocstyle]

@ -181,7 +181,7 @@ def extract_named_group(name: str, value: str, fmt_string: str) -> str:
def format_money( def format_money(
money: Money, money: Money,
decimal_places: Optional[int] = None, decimal_places: Optional[int] = None,
format: Optional[str] = None, fmt: Optional[str] = None,
include_symbol: bool = True, include_symbol: bool = True,
) -> str: ) -> str:
"""Format money object according to the currently set local. """Format money object according to the currently set local.
@ -189,7 +189,7 @@ def format_money(
Args: Args:
money (Money): The money object to format money (Money): The money object to format
decimal_places (int): Number of decimal places to use decimal_places (int): Number of decimal places to use
format (str): Format pattern according LDML / the babel format pattern syntax (https://babel.pocoo.org/en/latest/numbers.html) fmt (str): Format pattern according LDML / the babel format pattern syntax (https://babel.pocoo.org/en/latest/numbers.html)
Returns: Returns:
str: The formatted string str: The formatted string
@ -199,8 +199,8 @@ def format_money(
""" """
language = (None) or settings.LANGUAGE_CODE language = (None) or settings.LANGUAGE_CODE
locale = Locale.parse(translation.to_locale(language)) locale = Locale.parse(translation.to_locale(language))
if format: if fmt:
pattern = parse_pattern(format) pattern = parse_pattern(fmt)
else: else:
pattern = locale.currency_formats['standard'] pattern = locale.currency_formats['standard']
if decimal_places is not None: if decimal_places is not None:

@ -328,11 +328,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
request, self.get_form(), context=self.get_context_data() request, self.get_form(), context=self.get_context_data()
) )
def save(self, object, form, **kwargs): def save(self, obj, form, **kwargs):
"""Method for updating the object in the database. Default implementation is very simple, but can be overridden if required. """Method for updating the object in the database. Default implementation is very simple, but can be overridden if required.
Args: Args:
object: The current object, to be updated obj: The current object, to be updated
form: The validated form form: The validated form
Returns: Returns:

@ -136,7 +136,7 @@ class CurrencyExchangeView(APIView):
serializer_class = None serializer_class = None
@extend_schema(responses={200: common.serializers.CurrencyExchangeSerializer}) @extend_schema(responses={200: common.serializers.CurrencyExchangeSerializer})
def get(self, request, format=None): def get(self, request, fmt=None):
"""Return information on available currency conversions.""" """Return information on available currency conversions."""
# Extract a list of all available rates # Extract a list of all available rates
try: try:
@ -563,7 +563,7 @@ class BackgroundTaskOverview(APIView):
permission_classes = [permissions.IsAuthenticated, IsAdminUser] permission_classes = [permissions.IsAuthenticated, IsAdminUser]
serializer_class = None serializer_class = None
def get(self, request, format=None): def get(self, request, fmt=None):
"""Return information about the current status of the background task queue.""" """Return information about the current status of the background task queue."""
import django_q.models as q_models import django_q.models as q_models

@ -444,35 +444,35 @@ def format_number(number, **kwargs):
@register.simple_tag @register.simple_tag
def format_datetime(datetime, timezone=None, format=None): def format_datetime(datetime, timezone=None, fmt=None):
"""Format a datetime object for display. """Format a datetime object for display.
Arguments: Arguments:
datetime: The datetime object to format datetime: The datetime object to format
timezone: The timezone to use for the date (defaults to the server timezone) timezone: The timezone to use for the date (defaults to the server timezone)
format: The format string to use (defaults to ISO formatting) fmt: The format string to use (defaults to ISO formatting)
""" """
datetime = InvenTree.helpers.to_local_time(datetime, timezone) datetime = InvenTree.helpers.to_local_time(datetime, timezone)
if format: if fmt:
return datetime.strftime(format) return datetime.strftime(fmt)
else: else:
return datetime.isoformat() return datetime.isoformat()
@register.simple_tag @register.simple_tag
def format_date(date, timezone=None, format=None): def format_date(date, timezone=None, fmt=None):
"""Format a date object for display. """Format a date object for display.
Arguments: Arguments:
date: The date to format date: The date to format
timezone: The timezone to use for the date (defaults to the server timezone) timezone: The timezone to use for the date (defaults to the server timezone)
format: The format string to use (defaults to ISO formatting) fmt: The format string to use (defaults to ISO formatting)
""" """
date = InvenTree.helpers.to_local_time(date, timezone).date() date = InvenTree.helpers.to_local_time(date, timezone).date()
if format: if fmt:
return date.strftime(format) return date.strftime(fmt)
else: else:
return date.isoformat() return date.isoformat()