mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
fix a number of A002 cases
This commit is contained in:
parent
377a416cbc
commit
78e9de2179
@ -200,12 +200,13 @@ def define_env(env):
|
||||
return assets
|
||||
|
||||
@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.
|
||||
|
||||
Arguments:
|
||||
- filename: The name of the file to include (relative to the top-level directory)
|
||||
- title:
|
||||
- fmt:
|
||||
"""
|
||||
here = os.path.dirname(__file__)
|
||||
path = os.path.join(here, '..', filename)
|
||||
@ -218,7 +219,7 @@ def define_env(env):
|
||||
content = f.read()
|
||||
|
||||
data = f'??? abstract "{title}"\n\n'
|
||||
data += f' ```{format}\n'
|
||||
data += f' ```{fmt}\n'
|
||||
data += textwrap.indent(content, ' ')
|
||||
data += '\n\n'
|
||||
data += ' ```\n\n'
|
||||
@ -233,7 +234,7 @@ def define_env(env):
|
||||
'src', 'backend', 'InvenTree', 'report', 'templates', filename
|
||||
)
|
||||
|
||||
return includefile(fn, f'Template: {base}', format='html')
|
||||
return includefile(fn, f'Template: {base}', fmt='html')
|
||||
|
||||
@env.macro
|
||||
def rendersetting(setting: dict):
|
||||
|
@ -59,7 +59,7 @@ ignore = [
|
||||
"B904",
|
||||
|
||||
# Remove fast
|
||||
"A001", "A002","A003","B018"
|
||||
"A001", "A002", "B018"
|
||||
]
|
||||
|
||||
[tool.ruff.lint.pydocstyle]
|
||||
|
@ -181,7 +181,7 @@ def extract_named_group(name: str, value: str, fmt_string: str) -> str:
|
||||
def format_money(
|
||||
money: Money,
|
||||
decimal_places: Optional[int] = None,
|
||||
format: Optional[str] = None,
|
||||
fmt: Optional[str] = None,
|
||||
include_symbol: bool = True,
|
||||
) -> str:
|
||||
"""Format money object according to the currently set local.
|
||||
@ -189,7 +189,7 @@ def format_money(
|
||||
Args:
|
||||
money (Money): The money object to format
|
||||
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:
|
||||
str: The formatted string
|
||||
@ -199,8 +199,8 @@ def format_money(
|
||||
"""
|
||||
language = (None) or settings.LANGUAGE_CODE
|
||||
locale = Locale.parse(translation.to_locale(language))
|
||||
if format:
|
||||
pattern = parse_pattern(format)
|
||||
if fmt:
|
||||
pattern = parse_pattern(fmt)
|
||||
else:
|
||||
pattern = locale.currency_formats['standard']
|
||||
if decimal_places is not None:
|
||||
|
@ -328,11 +328,11 @@ class AjaxUpdateView(AjaxMixin, UpdateView):
|
||||
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.
|
||||
|
||||
Args:
|
||||
object: The current object, to be updated
|
||||
obj: The current object, to be updated
|
||||
form: The validated form
|
||||
|
||||
Returns:
|
||||
|
@ -136,7 +136,7 @@ class CurrencyExchangeView(APIView):
|
||||
serializer_class = None
|
||||
|
||||
@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."""
|
||||
# Extract a list of all available rates
|
||||
try:
|
||||
@ -563,7 +563,7 @@ class BackgroundTaskOverview(APIView):
|
||||
permission_classes = [permissions.IsAuthenticated, IsAdminUser]
|
||||
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."""
|
||||
import django_q.models as q_models
|
||||
|
||||
|
@ -444,35 +444,35 @@ def format_number(number, **kwargs):
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
Arguments:
|
||||
datetime: The datetime object to format
|
||||
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)
|
||||
|
||||
if format:
|
||||
return datetime.strftime(format)
|
||||
if fmt:
|
||||
return datetime.strftime(fmt)
|
||||
else:
|
||||
return datetime.isoformat()
|
||||
|
||||
|
||||
@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.
|
||||
|
||||
Arguments:
|
||||
date: The date to format
|
||||
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()
|
||||
|
||||
if format:
|
||||
return date.strftime(format)
|
||||
if fmt:
|
||||
return date.strftime(fmt)
|
||||
else:
|
||||
return date.isoformat()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user