Marco Ricci commited on 2025-01-15 20:09:20
Zeige 2 geänderte Dateien mit 9 Einfügungen und 27 Löschungen.
... | ... |
@@ -366,9 +366,7 @@ class TranslatableString(NamedTuple): |
366 | 366 |
ValueError: Missing format string parameters ... |
367 | 367 |
|
368 | 368 |
""" |
369 |
- all_flags = frozenset( |
|
370 |
- f.strip() for f in self.flags.union(extra_flags) |
|
371 |
- ) |
|
369 |
+ all_flags = frozenset(f.strip() for f in self.flags.union(extra_flags)) |
|
372 | 370 |
if '{' in self.singular and not bool( |
373 | 371 |
all_flags & {'python-brace-format', 'no-python-brace-format'} |
374 | 372 |
): |
... | ... |
@@ -410,9 +408,7 @@ def translatable( |
410 | 408 |
|
411 | 409 |
""" |
412 | 410 |
flags = ( |
413 |
- frozenset(flags) |
|
414 |
- if not isinstance(flags, str) |
|
415 |
- else frozenset({flags}) |
|
411 |
+ frozenset(flags) if not isinstance(flags, str) else frozenset({flags}) |
|
416 | 412 |
) |
417 | 413 |
return ( |
418 | 414 |
TranslatableString(context, single, plural=plural, flags=flags) |
... | ... |
@@ -425,11 +421,7 @@ def translatable( |
425 | 421 |
class TranslatedString: |
426 | 422 |
def __init__( |
427 | 423 |
self, |
428 |
- template: ( |
|
429 |
- str |
|
430 |
- | TranslatableString |
|
431 |
- | MsgTemplate |
|
432 |
- ), |
|
424 |
+ template: str | TranslatableString | MsgTemplate, |
|
433 | 425 |
args_dict: Mapping[str, Any] = types.MappingProxyType({}), |
434 | 426 |
/, |
435 | 427 |
**kwargs: Any, # noqa: ANN401 |
... | ... |
@@ -524,10 +516,7 @@ class _TranslatedStringConstructor(Protocol): |
524 | 516 |
) -> TranslatableString: ... |
525 | 517 |
|
526 | 518 |
|
527 |
-def _Commented( # noqa: N802 |
|
528 |
- comments: str = '', |
|
529 |
- / |
|
530 |
-) -> _TranslatedStringConstructor: |
|
519 |
+def _Commented(comments: str = '', /) -> _TranslatedStringConstructor: # noqa: N802 |
|
531 | 520 |
"""A "decorator" for readably constructing commented enum values. |
532 | 521 |
|
533 | 522 |
This is geared towards the quirks of the API documentation extractor |
... | ... |
@@ -560,8 +549,7 @@ class Label(enum.Enum): |
560 | 549 |
'Label :: Diagnostics :: Marker', |
561 | 550 |
'Warning', |
562 | 551 |
) |
563 |
- CANNOT_UPDATE_SETTINGS_METAVAR_SETTINGS_TYPE_GLOBAL = ( |
|
564 |
- _Commented( |
|
552 |
+ CANNOT_UPDATE_SETTINGS_METAVAR_SETTINGS_TYPE_GLOBAL = _Commented( |
|
565 | 553 |
'This is one of two values of the settings_type metavar ' |
566 | 554 |
'used in the CANNOT_UPDATE_SETTINGS_NO_SETTINGS entry. ' |
567 | 555 |
'It is only used there. ' |
... | ... |
@@ -571,9 +559,7 @@ class Label(enum.Enum): |
571 | 559 |
'Label :: Error message :: Metavar', |
572 | 560 |
'global settings', |
573 | 561 |
) |
574 |
- ) |
|
575 |
- CANNOT_UPDATE_SETTINGS_METAVAR_SETTINGS_TYPE_SERVICE = ( |
|
576 |
- _Commented( |
|
562 |
+ CANNOT_UPDATE_SETTINGS_METAVAR_SETTINGS_TYPE_SERVICE = _Commented( |
|
577 | 563 |
'This is one of two values of the settings_type metavar ' |
578 | 564 |
'used in the CANNOT_UPDATE_SETTINGS_NO_SETTINGS entry. ' |
579 | 565 |
'It is only used there. ' |
... | ... |
@@ -584,7 +570,6 @@ class Label(enum.Enum): |
584 | 570 |
'Label :: Error message :: Metavar', |
585 | 571 |
'service-specific settings', |
586 | 572 |
) |
587 |
- ) |
|
588 | 573 |
DERIVEPASSPHRASE_01 = _Commented( |
589 | 574 |
'This is the first paragraph of the command help text, ' |
590 | 575 |
'but it also appears (in truncated form, if necessary) ' |
... | ... |
@@ -1901,8 +1886,7 @@ MSG_TEMPLATE_CLASSES = ( |
1901 | 1886 |
DebugTranslations._load_cache() # noqa: SLF001 |
1902 | 1887 |
|
1903 | 1888 |
|
1904 |
- |
|
1905 |
-def _write_po_file( # noqa: C901 |
|
1889 |
+def _write_po_file( # noqa: C901,PLR0912 |
|
1906 | 1890 |
fileobj: TextIO, |
1907 | 1891 |
/, |
1908 | 1892 |
*, |
... | ... |
@@ -2046,7 +2030,7 @@ def _format_po_info( |
2046 | 2030 |
|
2047 | 2031 |
for key in sorted(data.keys(), key=_sort_position): |
2048 | 2032 |
value = data[key] |
2049 |
- line = f"{key}: {value}\n" |
|
2033 |
+ line = f'{key}: {value}\n' |
|
2050 | 2034 |
yield _cstr(line) |
2051 | 2035 |
|
2052 | 2036 |
|
... | ... |
@@ -66,9 +65,7 @@ class TestL10nMachineryWithDebugTranslations: |
66 | 65 |
if e.value.fields() == ['error', 'filename'] |
67 | 66 |
) |
68 | 67 |
no_fields_messages = tuple( |
69 |
- e |
|
70 |
- for e in all_translatable_strings_enum_values |
|
71 |
- if not e.value.fields() |
|
68 |
+ e for e in all_translatable_strings_enum_values if not e.value.fields() |
|
72 | 69 |
) |
73 | 70 |
|
74 | 71 |
@hypothesis.given(value=strategies.text(max_size=100)) |
75 | 72 |