prettycsharp 1.1.9__tar.gz → 1.1.10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/CHANGELOG.md +9 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/DESIGN.md +8 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/PKG-INFO +1 -1
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/__init__.py +1 -1
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/printer/expressions.py +32 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_layout.py +44 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.gitattributes +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/codeql/codeql-config.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/dependabot.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/build.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/build.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/fuzz.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/fuzz.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/pip-audit.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/pip-audit.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/runtime.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/runtime.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/test.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/test.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/zizmor.in +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/requirements/zizmor.txt +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/accepted.toml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/clamav/Dockerfile +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/malware-accepted.toml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/semgrep/Dockerfile +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/yara.json +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/security/yara_update.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/auto-merge.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/ci.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/fuzz.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/malware-scan.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/publish.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/scorecard.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/security.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/workflows/update-yara-rules.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.github/zizmor.yml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/.gitignore +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/AGENTS.md +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/CLAUDE.md +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/LICENSE +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/README.md +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/SECURITY.md +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/fuzz/fuzz_formatter.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/pyproject.toml +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/scripts/security/malware_report.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/scripts/security/security_report.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/__main__.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/cli.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/conditional.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/config.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/doc.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/formatter.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/ignore.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/isolate.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/parsing.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/printer/__init__.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/printer/core.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/printer/declarations.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/printer/statements.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/project.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/py.typed +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/rewrites.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/settings.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/syntax.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/src/prettycsharp/verify.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/comment_only_accessor_list.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/conditional_assignments.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/declarations.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/directives.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/embedded_statements.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/expressions.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/members.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/order.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/queries_and_patterns.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/split_by_conditionals.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/statements.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/strings.cs +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/support.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_cli.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_conditional.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_config.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_doc.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_docs.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_format_around.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_fuzz_corpus.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_grammar_compatibility.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_ignore.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_parsing.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_project.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_rewrites.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_settings.py +0 -0
- {prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/test_verify.py +0 -0
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Each release's section becomes the body of its GitHub release.
|
|
4
4
|
|
|
5
|
+
## [1.1.10] - 2026-10-18
|
|
6
|
+
|
|
7
|
+
- A tuple argument ending in a multiline block lambda closes the tuple and
|
|
8
|
+
call parentheses on their own line at the call's indentation, matching
|
|
9
|
+
Visual Studio's formatting. Ordinary lambda arguments keep their layout.
|
|
10
|
+
- Empty argument parentheses without interior comments stay together as
|
|
11
|
+
`()`. Long empty-constructor assignments break after `=` instead of
|
|
12
|
+
splitting the parentheses. Interior comments are preserved.
|
|
13
|
+
|
|
5
14
|
## [1.1.9] - 2026-10-18
|
|
6
15
|
|
|
7
16
|
- With the default `binary_wrap`, multiline conditions in catch filters,
|
|
@@ -177,6 +177,14 @@ parenthesis unless all three clauses are empty: `for (; ; )`.
|
|
|
177
177
|
| `ternary_wrap` | `before`: break before `?` and `:` when too long | `after`, `always` |
|
|
178
178
|
| `lambda_body` | `hug`: the last argument hangs off the call line when it is a lambda with a block body or a broken member chain, or a creation with a broken initializer | `argument` |
|
|
179
179
|
|
|
180
|
+
With `lambda_body = "hug"` and `argument_wrap = "one_per_line"`, a single
|
|
181
|
+
tuple argument ending in a multiline block lambda closes both enclosing
|
|
182
|
+
parentheses on their own line at the call's indentation.
|
|
183
|
+
|
|
184
|
+
Empty argument parentheses without interior comments stay together as `()`.
|
|
185
|
+
An overlong assignment to an empty constructor breaks after `=` instead of
|
|
186
|
+
splitting the empty parentheses.
|
|
187
|
+
|
|
180
188
|
`binary_wrap` also controls line breaks in `or` and `and` patterns.
|
|
181
189
|
With `before_operator_paren_own_line`, broken conditions in catch
|
|
182
190
|
filters, `if`, `while`, and `do` loops put the expression below `(` and `)`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: prettycsharp
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.10
|
|
4
4
|
Summary: An opinionated formatter for C#, in the spirit of Prettier
|
|
5
5
|
Project-URL: Homepage, https://github.com/WilliamSmithEdward/prettyCSharp
|
|
6
6
|
Project-URL: Repository, https://github.com/WilliamSmithEdward/prettyCSharp
|
|
@@ -4,7 +4,7 @@ from prettycsharp.formatter import FormatResult, FormattingError, format_details
|
|
|
4
4
|
from prettycsharp.parsing import CSharpSyntaxError
|
|
5
5
|
from prettycsharp.settings import Settings, SettingsError
|
|
6
6
|
|
|
7
|
-
__version__ = "1.1.
|
|
7
|
+
__version__ = "1.1.10"
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
"CSharpSyntaxError",
|
|
@@ -228,6 +228,14 @@ class Expressions(Core):
|
|
|
228
228
|
if value.verbatim:
|
|
229
229
|
return False
|
|
230
230
|
kind = value.type
|
|
231
|
+
if kind in ("object_creation_expression", "implicit_object_creation_expression") and not self.block_like(value):
|
|
232
|
+
arguments = value.first_of("argument_list")
|
|
233
|
+
if arguments is not None and len(arguments.children) == 2:
|
|
234
|
+
opening, closing = arguments.children
|
|
235
|
+
if not opening.trailing and not closing.leading:
|
|
236
|
+
# An empty constructor cannot break internally; move the
|
|
237
|
+
# whole value after the assignment operator when needed.
|
|
238
|
+
return False
|
|
231
239
|
if kind in _SELF_BREAKING:
|
|
232
240
|
return True
|
|
233
241
|
if kind == "await_expression":
|
|
@@ -461,7 +469,31 @@ class Expressions(Core):
|
|
|
461
469
|
close_tok = node.children[-1]
|
|
462
470
|
items, commas = self.items_and_commas(node)
|
|
463
471
|
if not items:
|
|
472
|
+
if not open_tok.trailing and not close_tok.leading:
|
|
473
|
+
return [self.tok(open_tok), self.tok(close_tok)]
|
|
464
474
|
return group([self.tok(open_tok), self.closing(close_tok, SOFTLINE)])
|
|
475
|
+
if (
|
|
476
|
+
node.type == "argument_list" and self.settings.lambda_body == "hug"
|
|
477
|
+
and self.settings.argument_wrap == "one_per_line" and len(items) == 1 and len(items[0]) == 1
|
|
478
|
+
):
|
|
479
|
+
argument = items[0][0]
|
|
480
|
+
target = argument.children[-1] if argument.type == "argument" and len(argument.children) == 1 else argument
|
|
481
|
+
if target.type == "tuple_expression" and not target.verbatim:
|
|
482
|
+
tuple_items, tuple_commas = self.items_and_commas(target)
|
|
483
|
+
last = tuple_items[-1][0] if tuple_items and len(tuple_items[-1]) == 1 else None
|
|
484
|
+
value = last.children[-1] if last is not None and last.type == "argument" and last.children else last
|
|
485
|
+
body = value.child("body") if value is not None and value.type == "lambda_expression" else None
|
|
486
|
+
if (
|
|
487
|
+
body is not None and body.type == "block" and self._can_hug(tuple_items)
|
|
488
|
+
and (len(body.children) > 2 or any(t.leading or t.trailing for t in body.tokens()))
|
|
489
|
+
):
|
|
490
|
+
# Keep the tuple's lambda with the call header, but close
|
|
491
|
+
# both parentheses at the call's indentation after its body.
|
|
492
|
+
tuple_docs = self._comma_docs(tuple_items, tuple_commas)
|
|
493
|
+
return [
|
|
494
|
+
self.tok(open_tok), indent([self.tok(target.children[0]), join(" ", tuple_docs)]),
|
|
495
|
+
self.closing(target.children[-1], HARDLINE), self.closing(close_tok, ""),
|
|
496
|
+
]
|
|
465
497
|
docs = [self.print_item(item) for item in items]
|
|
466
498
|
for i, comma in enumerate(commas):
|
|
467
499
|
if i < len(docs):
|
|
@@ -896,6 +896,30 @@ def test_empty_collection_moves_to_the_next_line_whole() -> None:
|
|
|
896
896
|
)
|
|
897
897
|
|
|
898
898
|
|
|
899
|
+
def test_long_empty_constructor_keeps_parentheses_together() -> None:
|
|
900
|
+
check(
|
|
901
|
+
'private readonly ConcurrentDictionary<IPAddress, ConcurrentBag<long>> _failRegexMatches = '
|
|
902
|
+
'new ConcurrentDictionary<IPAddress, ConcurrentBag<long>>();',
|
|
903
|
+
'private readonly ConcurrentDictionary<IPAddress, ConcurrentBag<long>> _failRegexMatches =\n'
|
|
904
|
+
' new ConcurrentDictionary<IPAddress, ConcurrentBag<long>>();\n',
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
@pytest.mark.parametrize("wrap", ["one_per_line", "one_per_line_close_on_last", "fill", "align"])
|
|
909
|
+
def test_empty_call_parentheses_never_split(wrap: str) -> None:
|
|
910
|
+
check(
|
|
911
|
+
'SomeVeryLongMethodName();', 'SomeVeryLongMethodName();\n',
|
|
912
|
+
max_line_length=12, argument_wrap=wrap,
|
|
913
|
+
)
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
def test_comments_inside_empty_constructor_are_preserved() -> None:
|
|
917
|
+
source = 'var instance = new Item( // Keep this note.\n);'
|
|
918
|
+
output = fmt(source)
|
|
919
|
+
assert '// Keep this note.\n' in output
|
|
920
|
+
assert fmt(output) == output
|
|
921
|
+
|
|
922
|
+
|
|
899
923
|
def test_spread_elements_are_spaced_and_ranges_are_not() -> None:
|
|
900
924
|
assert fmt("x = [..entries, 1, ..more];\n") == "x = [.. entries, 1, .. more];\n"
|
|
901
925
|
assert fmt("var r = entries[1..] + entries[..2] + entries[..];\n") == (
|
|
@@ -1080,6 +1104,26 @@ def test_auto_properties_and_empty_bodies_stay_on_one_line() -> None:
|
|
|
1080
1104
|
)
|
|
1081
1105
|
|
|
1082
1106
|
|
|
1107
|
+
def test_tuple_block_lambda_closes_parentheses_on_the_call_line_indent() -> None:
|
|
1108
|
+
check(
|
|
1109
|
+
'_dataHandlerPairs.Add((data, (ctx, route) => { handler(ctx, route); return Task.CompletedTask; }));',
|
|
1110
|
+
'_dataHandlerPairs.Add((data, (ctx, route) =>\n'
|
|
1111
|
+
' {\n handler(ctx, route);\n return Task.CompletedTask;\n }\n));\n',
|
|
1112
|
+
)
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
def test_ordinary_block_lambda_argument_keeps_hugged_parenthesis() -> None:
|
|
1116
|
+
check(
|
|
1117
|
+
'Run(data, (ctx, route) => { handler(ctx, route); return Task.CompletedTask; });',
|
|
1118
|
+
'Run(data, (ctx, route) =>\n'
|
|
1119
|
+
'{\n handler(ctx, route);\n return Task.CompletedTask;\n});\n',
|
|
1120
|
+
)
|
|
1121
|
+
|
|
1122
|
+
|
|
1123
|
+
def test_empty_tuple_lambda_stays_inline() -> None:
|
|
1124
|
+
check('Run((data, () => { }));', 'Run((data, () => { }));\n')
|
|
1125
|
+
|
|
1126
|
+
|
|
1083
1127
|
def test_object_initializer_hugs_the_last_argument() -> None:
|
|
1084
1128
|
check(
|
|
1085
1129
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/comment_only_accessor_list.cs
RENAMED
|
File without changes
|
{prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/conditional_assignments.cs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{prettycsharp-1.1.9 → prettycsharp-1.1.10}/tests/fuzz_corpus/csharp/split_by_conditionals.cs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|