Format everything with ruff (v0.6.9)
Marco Ricci

Marco Ricci commited on 2025-01-07 22:44:39
Zeige 3 geänderte Dateien mit 73 Einfügungen und 84 Löschungen.

... ...
@@ -1161,7 +1162,7 @@ def _is_completable_item(obj: object) -> bool:
1161 1162
 
1162 1163
     """
1163 1164
     obj = str(obj)
1164
-    forbidden = frozenset(chr(i) for i in range(32)) | {'\x7F'}
1165
+    forbidden = frozenset(chr(i) for i in range(32)) | {'\x7f'}
1165 1166
     return not any(f in obj for f in forbidden)
1166 1167
 
1167 1168
 
... ...
@@ -295,7 +295,7 @@ class TestAllCLI:
295 295
             (['export', 'vault'], ['--format', 'this-format-doesnt-exist']),
296 296
             (['vault'], []),
297 297
             (['vault'], ['--export', './']),
298
-        ]
298
+        ],
299 299
     )
300 300
     @pytest.mark.parametrize('arguments', [['--help'], ['--version']])
301 301
     def test_200_eager_options(
... ...
@@ -328,7 +328,7 @@ class TestAllCLI:
328 328
                 ['vault', '--import', '-'],
329 329
                 '{"services": {"": {"length": 20}}}',
330 330
             ),
331
-        ]
331
+        ],
332 332
     )
333 333
     def test_201_no_color_force_color(
334 334
         self,
... ...
@@ -3544,7 +3547,7 @@ def zsh_format(item: click.shell_completion.CompletionItem) -> str:
3544 3547
 
3545 3548
 
3546 3549
 def completion_item(
3547
-    item: str | click.shell_completion.CompletionItem
3550
+    item: str | click.shell_completion.CompletionItem,
3548 3551
 ) -> click.shell_completion.CompletionItem:
3549 3552
     return (
3550 3553
         click.shell_completion.CompletionItem(item, type='plain')
... ...
@@ -3554,7 +3557,7 @@ def completion_item(
3554 3557
 
3555 3558
 
3556 3559
 def assertable_item(
3557
-    item: str | click.shell_completion.CompletionItem
3560
+    item: str | click.shell_completion.CompletionItem,
3558 3561
 ) -> tuple[str, Any, str | None]:
3559 3562
     item = completion_item(item)
3560 3563
     return (item.type, item.value, item.help)
... ...
@@ -3596,7 +3598,7 @@ class TestShellCompletion:
3596 3598
             ('\x7f', False),
3597 3599
             ('service with spaces', True),
3598 3600
             ('service\nwith\nnewlines', False),
3599
-        ]
3601
+        ],
3600 3602
     )
3601 3603
     def test_100_is_completable_item(
3602 3604
         self,
... ...
@@ -3766,39 +3768,39 @@ class TestShellCompletion:
3766 3768
         file = click.shell_completion.CompletionItem('', type='file')
3767 3769
         completions = frozenset({(file.type, file.value, file.help)})
3768 3770
         comp = self.Completions(command_prefix, incomplete)
3769
-        assert frozenset(
3770
-            (x.type, x.value, x.help) for x in comp()
3771
-        ) == completions
3771
+        assert (
3772
+            frozenset((x.type, x.value, x.help) for x in comp()) == completions
3773
+        )
3772 3774
 
3773 3775
     @pytest.mark.parametrize(
3774 3776
         ['config', 'incomplete', 'completions'],
3775 3777
         [
3776 3778
             pytest.param(
3777
-                {"services": {}},
3779
+                {'services': {}},
3778 3780
                 '',
3779 3781
                 frozenset(),
3780 3782
                 id='no_services',
3781 3783
             ),
3782 3784
             pytest.param(
3783
-                {"services": {}},
3785
+                {'services': {}},
3784 3786
                 'partial',
3785 3787
                 frozenset(),
3786 3788
                 id='no_services_partial',
3787 3789
             ),
3788 3790
             pytest.param(
3789
-                {"services": {DUMMY_SERVICE: {"length": 10}}},
3791
+                {'services': {DUMMY_SERVICE: {'length': 10}}},
3790 3792
                 '',
3791 3793
                 frozenset({DUMMY_SERVICE}),
3792 3794
                 id='one_service',
3793 3795
             ),
3794 3796
             pytest.param(
3795
-                {"services": {DUMMY_SERVICE: {"length": 10}}},
3797
+                {'services': {DUMMY_SERVICE: {'length': 10}}},
3796 3798
                 DUMMY_SERVICE[:4],
3797 3799
                 frozenset({DUMMY_SERVICE}),
3798 3800
                 id='one_service_partial',
3799 3801
             ),
3800 3802
             pytest.param(
3801
-                {"services": {DUMMY_SERVICE: {"length": 10}}},
3803
+                {'services': {DUMMY_SERVICE: {'length': 10}}},
3802 3804
                 DUMMY_SERVICE[-4:],
3803 3805
                 frozenset(),
3804 3806
                 id='one_service_partial_miss',
... ...
@@ -3833,7 +3835,7 @@ class TestShellCompletion:
3833 3835
         ['config', 'comp_func', 'args', 'incomplete', 'results'],
3834 3836
         [
3835 3837
             pytest.param(
3836
-                {"services": {DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy()}},
3838
+                {'services': {DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy()}},
3837 3839
                 cli._shell_complete_service,
3838 3840
                 ['vault'],
3839 3841
                 '',
... ...
@@ -3841,7 +3843,7 @@ class TestShellCompletion:
3841 3843
                 id='base_config-service',
3842 3844
             ),
3843 3845
             pytest.param(
3844
-                {"services": {}},
3846
+                {'services': {}},
3845 3847
                 cli._shell_complete_service,
3846 3848
                 ['vault'],
3847 3849
                 '',
... ...
@@ -3850,9 +3852,9 @@ class TestShellCompletion:
3850 3852
             ),
3851 3853
             pytest.param(
3852 3854
                 {
3853
-                    "services": {
3855
+                    'services': {
3854 3856
                         DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy(),
3855
-                        "newline\nin\nname": DUMMY_CONFIG_SETTINGS.copy(),
3857
+                        'newline\nin\nname': DUMMY_CONFIG_SETTINGS.copy(),
3856 3858
                     }
3857 3859
                 },
3858 3860
                 cli._shell_complete_service,
... ...
@@ -3863,9 +3865,9 @@ class TestShellCompletion:
3863 3865
             ),
3864 3866
             pytest.param(
3865 3867
                 {
3866
-                    "services": {
3868
+                    'services': {
3867 3869
                         DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy(),
3868
-                        "backspace\bin\bname": DUMMY_CONFIG_SETTINGS.copy(),
3870
+                        'backspace\bin\bname': DUMMY_CONFIG_SETTINGS.copy(),
3869 3871
                     }
3870 3872
                 },
3871 3873
                 cli._shell_complete_service,
... ...
@@ -3876,9 +3878,9 @@ class TestShellCompletion:
3876 3878
             ),
3877 3879
             pytest.param(
3878 3880
                 {
3879
-                    "services": {
3881
+                    'services': {
3880 3882
                         DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy(),
3881
-                        "colon:in:name": DUMMY_CONFIG_SETTINGS.copy(),
3883
+                        'colon:in:name': DUMMY_CONFIG_SETTINGS.copy(),
3882 3884
                     }
3883 3885
                 },
3884 3886
                 cli._shell_complete_service,
... ...
@@ -3889,13 +3891,13 @@ class TestShellCompletion:
3889 3891
             ),
3890 3892
             pytest.param(
3891 3893
                 {
3892
-                    "services": {
3894
+                    'services': {
3893 3895
                         DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy(),
3894
-                        "colon:in:name": DUMMY_CONFIG_SETTINGS.copy(),
3895
-                        "newline\nin\nname": DUMMY_CONFIG_SETTINGS.copy(),
3896
-                        "backspace\bin\bname": DUMMY_CONFIG_SETTINGS.copy(),
3897
-                        "nul\x00in\x00name": DUMMY_CONFIG_SETTINGS.copy(),
3898
-                        "del\x7fin\x7fname": DUMMY_CONFIG_SETTINGS.copy(),
3896
+                        'colon:in:name': DUMMY_CONFIG_SETTINGS.copy(),
3897
+                        'newline\nin\nname': DUMMY_CONFIG_SETTINGS.copy(),
3898
+                        'backspace\bin\bname': DUMMY_CONFIG_SETTINGS.copy(),
3899
+                        'nul\x00in\x00name': DUMMY_CONFIG_SETTINGS.copy(),
3900
+                        'del\x7fin\x7fname': DUMMY_CONFIG_SETTINGS.copy(),
3899 3901
                     }
3900 3902
                 },
3901 3903
                 cli._shell_complete_service,
... ...
@@ -3905,7 +3907,7 @@ class TestShellCompletion:
3905 3907
                 id='brittle_incompletable_multi_config-service',
3906 3908
             ),
3907 3909
             pytest.param(
3908
-                {"services": {DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy()}},
3910
+                {'services': {DUMMY_SERVICE: DUMMY_CONFIG_SETTINGS.copy()}},
3909 3911
                 cli._shell_complete_path,
3910 3912
                 ['vault', '--import'],
3911 3913
                 '',
... ...
@@ -3913,7 +3915,7 @@ class TestShellCompletion:
3913 3915
                 id='base_config-path',
3914 3916
             ),
3915 3917
             pytest.param(
3916
-                {"services": {}},
3918
+                {'services': {}},
3917 3919
                 cli._shell_complete_path,
3918 3920
                 ['vault', '--import'],
3919 3921
                 '',
... ...
@@ -3930,7 +3932,7 @@ class TestShellCompletion:
3930 3932
         config: _types.VaultConfig,
3931 3933
         comp_func: Callable[
3932 3934
             [click.Context, click.Parameter, str],
3933
-            list[str | click.shell_completion.CompletionItem]
3935
+            list[str | click.shell_completion.CompletionItem],
3934 3936
         ],
3935 3937
         args: list[str],
3936 3938
         incomplete: str,
... ...
@@ -3942,26 +3944,18 @@ class TestShellCompletion:
3942 3944
             runner=runner,
3943 3945
             vault_config=config,
3944 3946
         ):
3945
-            expected_items = [
3946
-                assertable_item(item)
3947
-                for item in results
3948
-            ]
3947
+            expected_items = [assertable_item(item) for item in results]
3949 3948
             expected_string = '\n'.join(
3950
-                format_func(completion_item(item))
3951
-                for item in results
3949
+                format_func(completion_item(item)) for item in results
3952 3950
             )
3953 3951
             manual_raw_items = comp_func(
3954 3952
                 click.Context(cli.derivepassphrase),
3955 3953
                 click.Argument(['sample_parameter']),
3956 3954
                 incomplete,
3957 3955
             )
3958
-            manual_items = [
3959
-                assertable_item(item)
3960
-                for item in manual_raw_items
3961
-            ]
3956
+            manual_items = [assertable_item(item) for item in manual_raw_items]
3962 3957
             manual_string = '\n'.join(
3963
-                format_func(completion_item(item))
3964
-                for item in manual_raw_items
3958
+                format_func(completion_item(item)) for item in manual_raw_items
3965 3959
             )
3966 3960
             assert manual_items == expected_items
3967 3961
             assert manual_string == expected_string
... ...
@@ -3981,10 +3975,7 @@ class TestShellCompletion:
3981 3975
             actual_raw_items = comp.get_completions(
3982 3976
                 *comp.get_completion_args()
3983 3977
             )
3984
-            actual_items = [
3985
-                assertable_item(item)
3986
-                for item in actual_raw_items
3987
-            ]
3978
+            actual_items = [assertable_item(item) for item in actual_raw_items]
3988 3979
             actual_string = comp.complete()
3989 3980
             assert actual_items == expected_items
3990 3981
             assert actual_string == expected_string
... ...
@@ -3995,9 +3986,9 @@ class TestShellCompletion:
3995 3986
         [
3996 3987
             pytest.param(
3997 3988
                 {
3998
-                    "services": {
3999
-                        DUMMY_SERVICE: {"length": 10},
4000
-                        "newline\nin\nname": {"length": 10},
3989
+                    'services': {
3990
+                        DUMMY_SERVICE: {'length': 10},
3991
+                        'newline\nin\nname': {'length': 10},
4001 3992
                     },
4002 3993
                 },
4003 3994
                 'newline\nin\nname',
... ...
@@ -4007,9 +3998,9 @@ class TestShellCompletion:
4007 3998
             ),
4008 3999
             pytest.param(
4009 4000
                 {
4010
-                    "services": {
4011
-                        DUMMY_SERVICE: {"length": 10},
4012
-                        "newline\nin\nname": {"length": 10},
4001
+                    'services': {
4002
+                        DUMMY_SERVICE: {'length': 10},
4003
+                        'newline\nin\nname': {'length': 10},
4013 4004
                     },
4014 4005
                 },
4015 4006
                 'newline\nin\nname',
... ...
@@ -4019,9 +4010,9 @@ class TestShellCompletion:
4019 4010
             ),
4020 4011
             pytest.param(
4021 4012
                 {
4022
-                    "services": {
4023
-                        DUMMY_SERVICE: {"length": 10},
4024
-                        "newline\nin\nname": {"length": 10},
4013
+                    'services': {
4014
+                        DUMMY_SERVICE: {'length': 10},
4015
+                        'newline\nin\nname': {'length': 10},
4025 4016
                     },
4026 4017
                 },
4027 4018
                 'newline\nin\nname',
... ...
@@ -4031,9 +4022,9 @@ class TestShellCompletion:
4031 4022
             ),
4032 4023
             pytest.param(
4033 4024
                 {
4034
-                    "services": {
4035
-                        DUMMY_SERVICE: {"length": 10},
4036
-                        "nul\x00in\x00name": {"length": 10},
4025
+                    'services': {
4026
+                        DUMMY_SERVICE: {'length': 10},
4027
+                        'nul\x00in\x00name': {'length': 10},
4037 4028
                     },
4038 4029
                 },
4039 4030
                 'nul\x00in\x00name',
... ...
@@ -4043,9 +4034,9 @@ class TestShellCompletion:
4043 4034
             ),
4044 4035
             pytest.param(
4045 4036
                 {
4046
-                    "services": {
4047
-                        DUMMY_SERVICE: {"length": 10},
4048
-                        "nul\x00in\x00name": {"length": 10},
4037
+                    'services': {
4038
+                        DUMMY_SERVICE: {'length': 10},
4039
+                        'nul\x00in\x00name': {'length': 10},
4049 4040
                     },
4050 4041
                 },
4051 4042
                 'nul\x00in\x00name',
... ...
@@ -4055,9 +4046,9 @@ class TestShellCompletion:
4055 4046
             ),
4056 4047
             pytest.param(
4057 4048
                 {
4058
-                    "services": {
4059
-                        DUMMY_SERVICE: {"length": 10},
4060
-                        "nul\x00in\x00name": {"length": 10},
4049
+                    'services': {
4050
+                        DUMMY_SERVICE: {'length': 10},
4051
+                        'nul\x00in\x00name': {'length': 10},
4061 4052
                     },
4062 4053
                 },
4063 4054
                 'nul\x00in\x00name',
... ...
@@ -4067,9 +4058,9 @@ class TestShellCompletion:
4067 4058
             ),
4068 4059
             pytest.param(
4069 4060
                 {
4070
-                    "services": {
4071
-                        DUMMY_SERVICE: {"length": 10},
4072
-                        "backspace\bin\bname": {"length": 10},
4061
+                    'services': {
4062
+                        DUMMY_SERVICE: {'length': 10},
4063
+                        'backspace\bin\bname': {'length': 10},
4073 4064
                     },
4074 4065
                 },
4075 4066
                 'backspace\bin\bname',
... ...
@@ -4079,9 +4070,9 @@ class TestShellCompletion:
4079 4070
             ),
4080 4071
             pytest.param(
4081 4072
                 {
4082
-                    "services": {
4083
-                        DUMMY_SERVICE: {"length": 10},
4084
-                        "backspace\bin\bname": {"length": 10},
4073
+                    'services': {
4074
+                        DUMMY_SERVICE: {'length': 10},
4075
+                        'backspace\bin\bname': {'length': 10},
4085 4076
                     },
4086 4077
                 },
4087 4078
                 'backspace\bin\bname',
... ...
@@ -4091,9 +4082,9 @@ class TestShellCompletion:
4091 4082
             ),
4092 4083
             pytest.param(
4093 4084
                 {
4094
-                    "services": {
4095
-                        DUMMY_SERVICE: {"length": 10},
4096
-                        "backspace\bin\bname": {"length": 10},
4085
+                    'services': {
4086
+                        DUMMY_SERVICE: {'length': 10},
4087
+                        'backspace\bin\bname': {'length': 10},
4097 4088
                     },
4098 4089
                 },
4099 4090
                 'backspace\bin\bname',
... ...
@@ -4103,9 +4094,9 @@ class TestShellCompletion:
4103 4094
             ),
4104 4095
             pytest.param(
4105 4096
                 {
4106
-                    "services": {
4107
-                        DUMMY_SERVICE: {"length": 10},
4108
-                        "del\x7fin\x7fname": {"length": 10},
4097
+                    'services': {
4098
+                        DUMMY_SERVICE: {'length': 10},
4099
+                        'del\x7fin\x7fname': {'length': 10},
4109 4100
                     },
4110 4101
                 },
4111 4102
                 'del\x7fin\x7fname',
... ...
@@ -4115,9 +4106,9 @@ class TestShellCompletion:
4115 4106
             ),
4116 4107
             pytest.param(
4117 4108
                 {
4118
-                    "services": {
4119
-                        DUMMY_SERVICE: {"length": 10},
4120
-                        "del\x7fin\x7fname": {"length": 10},
4109
+                    'services': {
4110
+                        DUMMY_SERVICE: {'length': 10},
4111
+                        'del\x7fin\x7fname': {'length': 10},
4121 4112
                     },
4122 4113
                 },
4123 4114
                 'del\x7fin\x7fname',
... ...
@@ -4127,9 +4118,9 @@ class TestShellCompletion:
4127 4118
             ),
4128 4119
             pytest.param(
4129 4120
                 {
4130
-                    "services": {
4131
-                        DUMMY_SERVICE: {"length": 10},
4132
-                        "del\x7fin\x7fname": {"length": 10},
4121
+                    'services': {
4122
+                        DUMMY_SERVICE: {'length': 10},
4123
+                        'del\x7fin\x7fname': {'length': 10},
4133 4124
                     },
4134 4125
                 },
4135 4126
                 'del\x7fin\x7fname',
... ...
@@ -136,7 +136,7 @@ class TestCLI:
136 136
         assert result.error_exit(
137 137
             error=(
138 138
                 "Cannot parse 'does-not-exist.txt' "
139
-                "as a valid vault-native config"
139
+                'as a valid vault-native config'
140 140
             ),
141 141
             record_tuples=caplog.record_tuples,
142 142
         ), 'expected error exit and known error message'
143 143