prettycsharp 1.1.1__tar.gz → 1.1.3__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.
Files changed (90) hide show
  1. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/CHANGELOG.md +13 -0
  2. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/DESIGN.md +8 -6
  3. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/PKG-INFO +3 -3
  4. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/README.md +2 -2
  5. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/__init__.py +1 -1
  6. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/printer/declarations.py +5 -2
  7. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/settings.py +3 -3
  8. prettycsharp-1.1.3/tests/fuzz_corpus/csharp/comment_only_accessor_list.cs +0 -0
  9. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_layout.py +54 -6
  10. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_rewrites.py +0 -1
  11. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_settings.py +8 -6
  12. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.gitattributes +0 -0
  13. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/codeql/codeql-config.yml +0 -0
  14. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/dependabot.yml +0 -0
  15. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/build.in +0 -0
  16. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/build.txt +0 -0
  17. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/fuzz.in +0 -0
  18. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/fuzz.txt +0 -0
  19. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/pip-audit.in +0 -0
  20. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/pip-audit.txt +0 -0
  21. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/runtime.in +0 -0
  22. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/runtime.txt +0 -0
  23. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/test.in +0 -0
  24. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/test.txt +0 -0
  25. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/zizmor.in +0 -0
  26. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/requirements/zizmor.txt +0 -0
  27. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/accepted.toml +0 -0
  28. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/clamav/Dockerfile +0 -0
  29. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/malware-accepted.toml +0 -0
  30. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/semgrep/Dockerfile +0 -0
  31. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/yara.json +0 -0
  32. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/security/yara_update.py +0 -0
  33. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/auto-merge.yml +0 -0
  34. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/ci.yml +0 -0
  35. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/fuzz.yml +0 -0
  36. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/malware-scan.yml +0 -0
  37. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/publish.yml +0 -0
  38. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/scorecard.yml +0 -0
  39. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/security.yml +0 -0
  40. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/workflows/update-yara-rules.yml +0 -0
  41. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.github/zizmor.yml +0 -0
  42. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/.gitignore +0 -0
  43. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/AGENTS.md +0 -0
  44. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/CLAUDE.md +0 -0
  45. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/LICENSE +0 -0
  46. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/SECURITY.md +0 -0
  47. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/fuzz/fuzz_formatter.py +0 -0
  48. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/pyproject.toml +0 -0
  49. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/scripts/security/malware_report.py +0 -0
  50. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/scripts/security/security_report.py +0 -0
  51. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/__main__.py +0 -0
  52. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/cli.py +0 -0
  53. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/conditional.py +0 -0
  54. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/config.py +0 -0
  55. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/doc.py +0 -0
  56. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/formatter.py +0 -0
  57. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/ignore.py +0 -0
  58. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/isolate.py +0 -0
  59. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/parsing.py +0 -0
  60. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/printer/__init__.py +0 -0
  61. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/printer/core.py +0 -0
  62. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/printer/expressions.py +0 -0
  63. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/printer/statements.py +0 -0
  64. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/project.py +0 -0
  65. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/py.typed +0 -0
  66. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/rewrites.py +0 -0
  67. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/syntax.py +0 -0
  68. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/src/prettycsharp/verify.py +0 -0
  69. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/declarations.cs +0 -0
  70. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/directives.cs +0 -0
  71. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/embedded_statements.cs +0 -0
  72. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/expressions.cs +0 -0
  73. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/members.cs +0 -0
  74. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/order.cs +0 -0
  75. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/queries_and_patterns.cs +0 -0
  76. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/split_by_conditionals.cs +0 -0
  77. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/statements.cs +0 -0
  78. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/fuzz_corpus/csharp/strings.cs +0 -0
  79. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/support.py +0 -0
  80. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_cli.py +0 -0
  81. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_conditional.py +0 -0
  82. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_config.py +0 -0
  83. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_doc.py +0 -0
  84. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_docs.py +0 -0
  85. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_format_around.py +0 -0
  86. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_fuzz_corpus.py +0 -0
  87. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_ignore.py +0 -0
  88. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_parsing.py +0 -0
  89. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_project.py +0 -0
  90. {prettycsharp-1.1.1 → prettycsharp-1.1.3}/tests/test_verify.py +0 -0
@@ -2,6 +2,19 @@
2
2
 
3
3
  Each release's section becomes the body of its GitHub release.
4
4
 
5
+ ## [1.1.3] - 2026-10-17
6
+
7
+ - A property's accessor list or an enum that holds only a comment no longer
8
+ gains a blank line each time the file is formatted. Found by fuzzing.
9
+
10
+ ## [1.1.2] - 2026-10-17
11
+
12
+ - Nothing is padded into columns by default any more: `align_assignments`,
13
+ `align_enum_values` and `align_switch_arms` now default to `false`, so each
14
+ `=` and `=>` has one space before it. Padded columns shift whenever one
15
+ line changes, and the diff then touches every line of the run. Set any of
16
+ the three to `true` to align as before.
17
+
5
18
  ## [1.1.1] - 2026-10-17
6
19
 
7
20
  - `syntax_errors = "format_around"` now works inside each view of a file
@@ -233,12 +233,14 @@ int[] codes = [200, 404];
233
233
 
234
234
  | Setting | Default | Alternatives |
235
235
  | --- | --- | --- |
236
- | `align_switch_arms` | `true` | `false` |
237
- | `align_assignments` | `true`: consecutive local assignments and field initializers | `false` |
238
- | `align_enum_values` | `true` | `false` |
239
-
240
- Only the `=` or `=>` aligns. Types and names are not put into columns. A run ends at a blank
241
- line or at any statement of a different kind.
236
+ | `align_switch_arms` | `false`: one space before each arm's `=>` | `true` |
237
+ | `align_assignments` | `false`: one space before each `=` | `true`: consecutive local assignments and field initializers |
238
+ | `align_enum_values` | `false`: one space before each `=` | `true` |
239
+
240
+ By default nothing is padded into columns: alignment shifts whenever one line
241
+ changes, and the diff touches every line of the run. Turned on, only the `=`
242
+ or `=>` aligns; types and names are not put into columns, and a run ends at a
243
+ blank line or at any statement of a different kind:
242
244
 
243
245
  ```csharp
244
246
  var id = order.Id;
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: prettycsharp
3
- Version: 1.1.1
3
+ Version: 1.1.3
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
@@ -47,7 +47,7 @@ Description-Content-Type: text/markdown
47
47
  An opinionated formatter for C#, written in Python, in the spirit of Prettier.
48
48
  It parses each file with [tree-sitter](https://tree-sitter.github.io/) and
49
49
  reprints the whole file in one consistent layout: braces, indentation, line
50
- breaks, blank lines, alignment and a few safe rewrites such as file-scoped
50
+ breaks, blank lines and a few safe rewrites such as file-scoped
51
51
  namespaces, sorted usings and expression-bodied members. It needs no .NET
52
52
  SDK.
53
53
 
@@ -175,7 +175,7 @@ Settings come from, highest precedence first:
175
175
  max_line_length = 100
176
176
  brace_style = "kr"
177
177
  continuation_keywords = "same_line"
178
- align_assignments = false
178
+ align_assignments = true
179
179
  ```
180
180
 
181
181
  Every setting, its default, its alternatives and an example of each layout
@@ -12,7 +12,7 @@
12
12
  An opinionated formatter for C#, written in Python, in the spirit of Prettier.
13
13
  It parses each file with [tree-sitter](https://tree-sitter.github.io/) and
14
14
  reprints the whole file in one consistent layout: braces, indentation, line
15
- breaks, blank lines, alignment and a few safe rewrites such as file-scoped
15
+ breaks, blank lines and a few safe rewrites such as file-scoped
16
16
  namespaces, sorted usings and expression-bodied members. It needs no .NET
17
17
  SDK.
18
18
 
@@ -140,7 +140,7 @@ Settings come from, highest precedence first:
140
140
  max_line_length = 100
141
141
  brace_style = "kr"
142
142
  continuation_keywords = "same_line"
143
- align_assignments = false
143
+ align_assignments = true
144
144
  ```
145
145
 
146
146
  Every setting, its default, its alternatives and an example of each layout
@@ -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.1"
7
+ __version__ = "1.1.3"
8
8
 
9
9
  __all__ = [
10
10
  "CSharpSyntaxError",
@@ -399,7 +399,7 @@ class Declarations(Statements):
399
399
  return [
400
400
  self.open_brace("type"),
401
401
  self.tok(open_tok),
402
- indent([HARDLINE, lines]),
402
+ indent([HARDLINE, lines]) if lines else "",
403
403
  self.close_comments(close_tok),
404
404
  HARDLINE,
405
405
  self.tok(close_tok, leading=False),
@@ -522,10 +522,13 @@ class Declarations(Statements):
522
522
  return [" ", self.tok(open_tok), " ", join(" ", [self.print(a) for a in accessors]), " ", self.tok(close_tok)]
523
523
  if not accessors and not close_tok.leading:
524
524
  return [" ", self.tok(open_tok), " ", self.tok(close_tok)]
525
+ body: Doc = ""
526
+ if accessors:
527
+ body = indent([HARDLINE, self.print_list(accessors, lambda a, b: self.has_blank_before(b))])
525
528
  return [
526
529
  self.open_brace("accessor"),
527
530
  self.tok(open_tok),
528
- indent([HARDLINE, self.print_list(accessors, lambda a, b: self.has_blank_before(b))]),
531
+ body,
529
532
  self.close_comments(close_tok),
530
533
  HARDLINE,
531
534
  self.tok(close_tok, leading=False),
@@ -70,9 +70,9 @@ class Settings:
70
70
  simple_lists_inline: bool = True
71
71
  trailing_commas: str = "remove"
72
72
 
73
- align_switch_arms: bool = True
74
- align_assignments: bool = True
75
- align_enum_values: bool = True
73
+ align_switch_arms: bool = False
74
+ align_assignments: bool = False
75
+ align_enum_values: bool = False
76
76
 
77
77
  switch_case_indent: bool = True
78
78
  switch_case_blank_lines: bool = True
@@ -131,7 +131,6 @@ def test_single_call_and_property_chains_stay_on_one_line() -> None:
131
131
  var city = order.Customer.Address.City;
132
132
  var zip = order.Customer.Address.GetPostalCode();
133
133
  """,
134
- align_assignments=False,
135
134
  )
136
135
 
137
136
 
@@ -230,7 +229,7 @@ def test_fields_grouped_tight_and_blank_lines_around_members_with_bodies() -> No
230
229
 
231
230
  public Order(int id, string name)
232
231
  {
233
- _id = id;
232
+ _id = id;
234
233
  _name = name;
235
234
  }
236
235
 
@@ -429,7 +428,6 @@ def test_simple_value_lists_stay_inline_and_complex_ones_break() -> None:
429
428
  new Point(1, 1)
430
429
  };
431
430
  """,
432
- align_assignments=False,
433
431
  )
434
432
 
435
433
 
@@ -513,7 +511,35 @@ def test_switch_sections_are_indented_with_blank_lines_between() -> None:
513
511
  )
514
512
 
515
513
 
516
- def test_switch_expression_arms_align_their_arrows() -> None:
514
+ def test_nothing_is_padded_into_columns() -> None:
515
+ check(
516
+ """
517
+ var label = status switch { Status.Paid => "Paid", Status.Pending => "Pending", _ => "Unknown" };
518
+ var id = order.Id;
519
+ var customer = order.Customer;
520
+ public enum Status { Pending = 0, Paid = 1, Cancelled = 2 }
521
+ """,
522
+ """
523
+ var label = status switch
524
+ {
525
+ Status.Paid => "Paid",
526
+ Status.Pending => "Pending",
527
+ _ => "Unknown"
528
+ };
529
+ var id = order.Id;
530
+ var customer = order.Customer;
531
+
532
+ public enum Status
533
+ {
534
+ Pending = 0,
535
+ Paid = 1,
536
+ Cancelled = 2
537
+ }
538
+ """,
539
+ )
540
+
541
+
542
+ def test_switch_expression_arms_align_when_turned_on() -> None:
517
543
  check(
518
544
  """
519
545
  var label = status switch { Status.Paid => "Paid", Status.Pending => "Pending", _ => "Unknown" };
@@ -526,10 +552,11 @@ def test_switch_expression_arms_align_their_arrows() -> None:
526
552
  _ => "Unknown"
527
553
  };
528
554
  """,
555
+ align_switch_arms=True,
529
556
  )
530
557
 
531
558
 
532
- def test_consecutive_assignments_and_enum_values_align() -> None:
559
+ def test_assignments_and_enum_values_align_when_turned_on() -> None:
533
560
  check(
534
561
  """
535
562
  var id = order.Id;
@@ -551,6 +578,8 @@ def test_consecutive_assignments_and_enum_values_align() -> None:
551
578
  Cancelled = 2
552
579
  }
553
580
  """,
581
+ align_assignments=True,
582
+ align_enum_values=True,
554
583
  )
555
584
 
556
585
 
@@ -678,6 +707,26 @@ def test_obvious_parentheses_are_removed_and_clarifying_ones_kept() -> None:
678
707
  )
679
708
 
680
709
 
710
+ def test_accessor_list_and_enum_holding_only_a_comment() -> None:
711
+ check(
712
+ "class C { int P {\n// c\n} }\nenum E {\n// c\n}\n",
713
+ """
714
+ class C
715
+ {
716
+ int P
717
+ {
718
+ // c
719
+ }
720
+ }
721
+
722
+ enum E
723
+ {
724
+ // c
725
+ }
726
+ """,
727
+ )
728
+
729
+
681
730
  def test_auto_properties_and_empty_bodies_stay_on_one_line() -> None:
682
731
  check(
683
732
  """
@@ -797,7 +846,6 @@ def test_raw_and_verbatim_strings_are_untouched() -> None:
797
846
  """;
798
847
  var path = @"C:\\orders\\ ";
799
848
  ''',
800
- align_assignments=False,
801
849
  )
802
850
 
803
851
 
@@ -262,7 +262,6 @@ def test_parentheses_remove_redundant_follows_precedence() -> None:
262
262
  var m = n - (o - p);
263
263
  """,
264
264
  parentheses="remove_redundant",
265
- align_assignments=False,
266
265
  )
267
266
 
268
267
 
@@ -238,13 +238,15 @@ def test_initializer_break_threshold_zero_and_simple_lists() -> None:
238
238
  assert fmt("var a = new[] { 1, 2 };\n", simple_lists_inline=False) == "var a = new[]\n{\n 1,\n 2\n};\n"
239
239
 
240
240
 
241
- def test_alignment_off() -> None:
241
+ def test_alignment_is_off_by_default_and_each_setting_turns_it_on() -> None:
242
242
  source = "var id = order.Id;\nvar customer = order.Customer;\n"
243
- assert fmt(source, align_assignments=False) == source
244
- assert fmt(
245
- "var l = s switch { 1 => \"a\", 22 => \"b\" };\n", align_switch_arms=False
246
- ) == 'var l = s switch\n{\n 1 => "a",\n 22 => "b"\n};\n'
247
- assert fmt("enum E { A = 1, Bb = 2 }\n", align_enum_values=False) == "enum E\n{\n A = 1,\n Bb = 2\n}\n"
243
+ assert fmt(source) == source
244
+ assert fmt(source, align_assignments=True) == "var id = order.Id;\nvar customer = order.Customer;\n"
245
+ switch = 'var l = s switch { 1 => "a", 22 => "b" };\n'
246
+ assert fmt(switch) == 'var l = s switch\n{\n 1 => "a",\n 22 => "b"\n};\n'
247
+ assert fmt(switch, align_switch_arms=True) == 'var l = s switch\n{\n 1 => "a",\n 22 => "b"\n};\n'
248
+ assert fmt("enum E { A = 1, Bb = 2 }\n") == "enum E\n{\n A = 1,\n Bb = 2\n}\n"
249
+ assert fmt("enum E { A = 1, Bb = 2 }\n", align_enum_values=True) == "enum E\n{\n A = 1,\n Bb = 2\n}\n"
248
250
 
249
251
 
250
252
  def test_switch_case_indent_and_blank_lines_off() -> None:
File without changes
File without changes
File without changes
File without changes
File without changes