-
-
Notifications
You must be signed in to change notification settings - Fork 260
Expand file tree
/
Copy pathdataclasses.po
More file actions
1631 lines (1478 loc) · 64.5 KB
/
dataclasses.po
File metadata and controls
1631 lines (1478 loc) · 64.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# Copyright (C) 2001-2018, Python Software Foundation
# For licence information, see README file.
#
msgid ""
msgstr ""
"Project-Id-Version: Python 3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-10-29 21:40+0100\n"
"PO-Revision-Date: 2023-03-20 09:44+0100\n"
"Last-Translator: David GIRAUD <davidgiraud@protonmail.com>\n"
"Language-Team: FRENCH <traductions@lists.afpy.org>\n"
"Language: fr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 3.2.1\n"
#: library/dataclasses.rst:2
#, fuzzy
msgid ":mod:`!dataclasses` --- Data Classes"
msgstr ":mod:`dataclasses` — Classes de données"
#: library/dataclasses.rst:10
msgid "**Source code:** :source:`Lib/dataclasses.py`"
msgstr "**Code source :** :source:`Lib/dataclasses.py`"
#: library/dataclasses.rst:14
#, fuzzy
msgid ""
"This module provides a decorator and functions for automatically adding "
"generated :term:`special methods <special method>` such as :meth:`~object."
"__init__` and :meth:`~object.__repr__` to user-defined classes. It was "
"originally described in :pep:`557`."
msgstr ""
"Ce module fournit un décorateur et des fonctions pour générer "
"automatiquement les :term:`méthodes spéciales <special method>` comme :meth:"
"`__init__` et :meth:`__repr__` dans les *Classes de Données* définies par "
"l’utilisateur. Ces classes ont été décrites dans la :pep:`557`."
#: library/dataclasses.rst:19
msgid ""
"The member variables to use in these generated methods are defined using :"
"pep:`526` type annotations. For example, this code::"
msgstr ""
"Les variables membres à utiliser dans ces méthodes générées sont définies en "
"utilisant les annotations de type :pep:`526`. Par exemple ::"
#: library/dataclasses.rst:22
msgid ""
"from dataclasses import dataclass\n"
"\n"
"@dataclass\n"
"class InventoryItem:\n"
" \"\"\"Class for keeping track of an item in inventory.\"\"\"\n"
" name: str\n"
" unit_price: float\n"
" quantity_on_hand: int = 0\n"
"\n"
" def total_cost(self) -> float:\n"
" return self.unit_price * self.quantity_on_hand"
msgstr ""
#: library/dataclasses.rst:34
#, fuzzy
msgid "will add, among other things, a :meth:`!__init__` that looks like::"
msgstr ""
"ce code ajoute à la classe, entre autres choses, une méthode :meth:"
"`__init__` qui ressemble à ::"
#: library/dataclasses.rst:36
msgid ""
"def __init__(self, name: str, unit_price: float, quantity_on_hand: int = "
"0):\n"
" self.name = name\n"
" self.unit_price = unit_price\n"
" self.quantity_on_hand = quantity_on_hand"
msgstr ""
#: library/dataclasses.rst:41
#, fuzzy
msgid ""
"Note that this method is automatically added to the class: it is not "
"directly specified in the :class:`!InventoryItem` definition shown above."
msgstr ""
"Il est important de noter que cette méthode est ajoutée automatiquement dans "
"la classe. Elle n’est jamais écrite dans la définition de ``InventoryItem``."
#: library/dataclasses.rst:47
msgid "Module contents"
msgstr "Classe de données"
#: library/dataclasses.rst:51
#, fuzzy
msgid ""
"This function is a :term:`decorator` that is used to add generated :term:"
"`special methods <special method>` to classes, as described below."
msgstr ""
"Cette fonction est un :term:`décorateur <decorator>` qui ajoute aux classes "
"des :term:`méthodes spéciales <special method>` générées automatiquement. "
"Voici une description plus détaillée."
#: library/dataclasses.rst:54
#, fuzzy
msgid ""
"The ``@dataclass`` decorator examines the class to find ``field``\\s. A "
"``field`` is defined as a class variable that has a :term:`type annotation "
"<variable annotation>`. With two exceptions described below, nothing in "
"``@dataclass`` examines the type specified in the variable annotation."
msgstr ""
"Le décorateur :func:`dataclass` examine la classe pour trouver des champs. "
"Un champ est défini comme une variable de classe qui possède une :term:"
"`annotation de type <variable annotation>`. À deux exceptions près décrites "
"plus bas, :func:`dataclass` ne prend pas en considération le type donné dans "
"l'annotation."
#: library/dataclasses.rst:60
msgid ""
"The order of the fields in all of the generated methods is the order in "
"which they appear in the class definition."
msgstr ""
"L’ordre des paramètres des méthodes générées est celui d’apparition des "
"champs dans la définition de la classe."
#: library/dataclasses.rst:63
#, fuzzy
msgid ""
"The ``@dataclass`` decorator will add various \"dunder\" methods to the "
"class, described below. If any of the added methods already exist in the "
"class, the behavior depends on the parameter, as documented below. The "
"decorator returns the same class that it is called on; no new class is "
"created."
msgstr ""
"Le décorateur :func:`dataclass` ajoute diverses méthodes spéciales à la "
"classe, décrites ci-après. Si l’une des méthodes ajoutées existe déjà dans "
"la classe, le comportement dépend des paramètres. Le décorateur renvoie la "
"classe sur laquelle il est appelé ; aucune nouvelle classe n'est créée."
#: library/dataclasses.rst:69
#, fuzzy
msgid ""
"If ``@dataclass`` is used just as a simple decorator with no parameters, it "
"acts as if it has the default values documented in this signature. That is, "
"these three uses of ``@dataclass`` are equivalent::"
msgstr ""
"Si :func:`dataclass` est utilisé directement, il se comporte comme si on "
"l’avait appelé sans argument (c.-à-d. en laissant les valeurs par défaut de "
"sa signature). Ainsi, les trois usages suivants de :func:`dataclass` sont "
"équivalents ::"
#: library/dataclasses.rst:74
msgid ""
"@dataclass\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass()\n"
"class C:\n"
" ...\n"
"\n"
"@dataclass(init=True, repr=True, eq=True, order=False, unsafe_hash=False, "
"frozen=False,\n"
" match_args=True, kw_only=False, slots=False, weakref_slot=False)\n"
"class C:\n"
" ..."
msgstr ""
#: library/dataclasses.rst:87
#, fuzzy
msgid "The parameters to ``@dataclass`` are:"
msgstr "Les paramètres de :func:`dataclass` sont les suivants :"
#: library/dataclasses.rst:89
#, fuzzy
msgid ""
"*init*: If true (the default), a :meth:`~object.__init__` method will be "
"generated."
msgstr ""
"*init* : si vrai (par défaut), une méthode :meth:`__init__` est générée."
#: library/dataclasses.rst:92
#, fuzzy
msgid ""
"If the class already defines :meth:`!__init__`, this parameter is ignored."
msgstr ""
"Si la classe définit déjà une méthode :meth:`__init__`, ce paramètre est "
"ignoré."
#: library/dataclasses.rst:95
#, fuzzy
msgid ""
"*repr*: If true (the default), a :meth:`~object.__repr__` method will be "
"generated. The generated repr string will have the class name and the name "
"and repr of each field, in the order they are defined in the class. Fields "
"that are marked as being excluded from the repr are not included. For "
"example: ``InventoryItem(name='widget', unit_price=3.0, "
"quantity_on_hand=10)``."
msgstr ""
"*repr* : si vrai (par défaut), une méthode :meth:`__repr__` est générée. La "
"chaîne de représentation comporte le nom de la classe et le nom ainsi que la "
"représentation de chaque champ, suivant leur ordre de définition. Les "
"champs marqués comme exclus de la représentation (voir ``Field`` ci-dessous) "
"sont ignorés. Par exemple : ``InventoryItem(name='widget', unit_price=3.0, "
"quantity_on_hand=10)``."
#: library/dataclasses.rst:102
#, fuzzy
msgid ""
"If the class already defines :meth:`!__repr__`, this parameter is ignored."
msgstr ""
"Si la classe définit déjà une méthode :meth:`__repr__`, ce paramètre est "
"ignoré."
#: library/dataclasses.rst:105
#, fuzzy
msgid ""
"*eq*: If true (the default), an :meth:`~object.__eq__` method will be "
"generated. This method compares the class as if it were a tuple of its "
"fields, in order. Both instances in the comparison must be of the identical "
"type."
msgstr ""
"*eq* : si vrai (par défaut), une méthode :meth:`__eq__` est générée. Cette "
"méthode permet de comparer les instances de la classe comme si elles étaient "
"des *n*-uplet de leurs champs, pris dans l’ordre. Les deux instances dans la "
"comparaison doivent être de même type."
#: library/dataclasses.rst:110
#, fuzzy
msgid ""
"If the class already defines :meth:`!__eq__`, this parameter is ignored."
msgstr ""
"Si la classe définit déjà une méthode :meth:`__eq__`, ce paramètre est "
"ignoré."
#: library/dataclasses.rst:113
#, fuzzy
msgid ""
"*order*: If true (the default is ``False``), :meth:`~object.__lt__`, :meth:"
"`~object.__le__`, :meth:`~object.__gt__`, and :meth:`~object.__ge__` methods "
"will be generated. These compare the class as if it were a tuple of its "
"fields, in order. Both instances in the comparison must be of the identical "
"type. If *order* is true and *eq* is false, a :exc:`ValueError` is raised."
msgstr ""
"*order* : si vrai (``False`` par défaut), les méthodes :meth:`__lt__`, :meth:"
"`__le__`, :meth:`__gt__`, et :meth:`__ge__` sont générées. Elles permettent "
"de comparer les instances de la classe en les considérant comme des *n*-"
"uplets, dans l’ordre de définition des champs. Toutes les instances dans la "
"comparaison doivent être de même type. Si ``order`` est vrai mais que "
"``eq`` est faux, une :exc:`ValueError` est levée."
#: library/dataclasses.rst:120
#, fuzzy
msgid ""
"If the class already defines any of :meth:`!__lt__`, :meth:`!__le__`, :meth:"
"`!__gt__`, or :meth:`!__ge__`, then :exc:`TypeError` is raised."
msgstr ""
"Si la classe définit déjà l’une des méthodes :meth:`__lt__`, :meth:"
"`__le__`, :meth:`__gt__`, ou :meth:`__ge__`, alors une :exc:`TypeError` est "
"levée."
#: library/dataclasses.rst:124
#, fuzzy
msgid ""
"*unsafe_hash*: If ``False`` (the default), a :meth:`~object.__hash__` method "
"is generated according to how *eq* and *frozen* are set."
msgstr ""
"*unsafe_hash* : si ``False`` (par défaut), une méthode :meth:`__hash__` est "
"générée et son comportement dépend des valeurs de *eq* et *frozen*."
#: library/dataclasses.rst:127
#, fuzzy
msgid ""
":meth:`!__hash__` is used by built-in :meth:`hash`, and when objects are "
"added to hashed collections such as dictionaries and sets. Having a :meth:`!"
"__hash__` implies that instances of the class are immutable. Mutability is a "
"complicated property that depends on the programmer's intent, the existence "
"and behavior of :meth:`!__eq__`, and the values of the *eq* and *frozen* "
"flags in the ``@dataclass`` decorator."
msgstr ""
":meth:`__hash__` est utilisée par la fonction native :meth:`hash()`, ainsi "
"que lorsqu’un objet est inséré dans une collection utilisant du hachage, tel "
"qu’un dictionnaire ou un ensemble. Avoir une méthode :meth:`__hash__` "
"implique que les instances de la classe sont immuables. La muabilité est une "
"propriété complexe qui dépend des intentions du programmeur, de l’existence "
"et du comportement de la méthode :meth:`__eq__`, et des valeurs des options "
"*eq* et *frozen* dans l’appel au décorateur :func:`dataclass`."
#: library/dataclasses.rst:134
#, fuzzy
msgid ""
"By default, ``@dataclass`` will not implicitly add a :meth:`~object."
"__hash__` method unless it is safe to do so. Neither will it add or change "
"an existing explicitly defined :meth:`!__hash__` method. Setting the class "
"attribute ``__hash__ = None`` has a specific meaning to Python, as described "
"in the :meth:`!__hash__` documentation."
msgstr ""
"Par défaut, :func:`dataclass` n’ajoute pas de méthode implicite :meth:"
"`__hash__`, sauf s’il n’existe aucun risque sous-jacent. Il n’ajoute ou ne "
"modifie pas non plus la méthode :meth:`__hash__` si elle a été définie "
"explicitement. Définir l’attribut de classe ``__hash__ = None`` a une "
"signification particulière, comme précisé dans la documentation de :meth:"
"`__hash__`."
#: library/dataclasses.rst:140
#, fuzzy
msgid ""
"If :meth:`!__hash__` is not explicitly defined, or if it is set to ``None``, "
"then ``@dataclass`` *may* add an implicit :meth:`!__hash__` method. Although "
"not recommended, you can force ``@dataclass`` to create a :meth:`!__hash__` "
"method with ``unsafe_hash=True``. This might be the case if your class is "
"logically immutable but can still be mutated. This is a specialized use case "
"and should be considered carefully."
msgstr ""
"Si :meth:`__hash__` n’est pas défini explicitement, ou s’il a pour valeur "
"``None``, alors :func:`dataclass` *peut* ajouter une méthode :meth:"
"`__hash__` implicite. Bien que ce ne soit pas recommandé, vous pouvez "
"forcer :func:`dataclass` à créer une méthode :meth:`__hash__` en utilisant "
"``unsafe_hash=True``. Cela pourrait être nécessaire si votre classe est "
"logiquement immuable mais qu’une mutation est tout de même possible. Il "
"s'agit là d'un cas particulier qui doit être considéré avec la plus grande "
"prudence."
#: library/dataclasses.rst:147
#, fuzzy
msgid ""
"Here are the rules governing implicit creation of a :meth:`!__hash__` "
"method. Note that you cannot both have an explicit :meth:`!__hash__` method "
"in your dataclass and set ``unsafe_hash=True``; this will result in a :exc:"
"`TypeError`."
msgstr ""
"Voici les règles autour de la création implicite de la méthode :meth:"
"`__hash__`. Il faut noter que vous ne pouvez pas avoir à la fois une "
"méthode :meth:`__hash__` explicite dans votre classe de données et définir "
"``unsafe_hash=True`` ; cela lèvera une :exc:`TypeError`."
#: library/dataclasses.rst:152
#, fuzzy
msgid ""
"If *eq* and *frozen* are both true, by default ``@dataclass`` will generate "
"a :meth:`!__hash__` method for you. If *eq* is true and *frozen* is false, :"
"meth:`!__hash__` will be set to ``None``, marking it unhashable (which it "
"is, since it is mutable). If *eq* is false, :meth:`!__hash__` will be left "
"untouched meaning the :meth:`!__hash__` method of the superclass will be "
"used (if the superclass is :class:`object`, this means it will fall back to "
"id-based hashing)."
msgstr ""
"Si *eq* et *frozen* sont tous deux vrais, :func:`dataclass` génère par "
"défaut une méthode :meth:`__hash__` pour vous. Si *eq* est vrai mais que "
"*frozen* est faux, :meth:`__hash__` prend la valeur ``None``, marquant la "
"classe comme non-hachable (et c’est le cas, puisque les instances sont "
"mutables). Si ``eq`` est faux, la méthode :meth:`__hash__` est laissée "
"intacte, ce qui veut dire que la méthode :meth:`__hash__` de la classe "
"parente sera utilisée (si la classe parente est :class:`object`, le "
"comportement est un hachage basé sur les id)."
#: library/dataclasses.rst:160
#, fuzzy
msgid ""
"*frozen*: If true (the default is ``False``), assigning to fields will "
"generate an exception. This emulates read-only frozen instances. If :meth:"
"`~object.__setattr__` or :meth:`~object.__delattr__` is defined in the "
"class, then :exc:`TypeError` is raised. See the discussion below."
msgstr ""
"*frozen* : si vrai (faux par défaut), assigner une valeur à un champ lève "
"une exception. Cela simule le comportement des instances figées en lecture "
"seule. Si la méthode :meth:`__setattr__` ou :meth:`__delattr__` est définie "
"sur la classe, alors une :exc:`TypeError` est levée. Voir la discussion ci-"
"dessous."
#: library/dataclasses.rst:165
#, fuzzy
msgid ""
"*match_args*: If true (the default is ``True``), the :attr:`~object."
"__match_args__` tuple will be created from the list of parameters to the "
"generated :meth:`~object.__init__` method (even if :meth:`!__init__` is not "
"generated, see above). If false, or if :attr:`!__match_args__` is already "
"defined in the class, then :attr:`!__match_args__` will not be generated."
msgstr ""
"*match_args* : si vrai (``True`` est la valeur par défaut), le *n*-uplet "
"``__match_args__`` est créé automatiquement depuis la liste des paramètres "
"de la méthode :meth:`__init__` générée (même si :meth:`__init__` n'est pas "
"générée, voir ci-dessus). Si faux ou si ``__match_args__`` est déjà défini "
"dans la classe alors ``__match_args__`` n'est pas créé."
#: library/dataclasses.rst:174
#, fuzzy
msgid ""
"*kw_only*: If true (the default value is ``False``), then all fields will be "
"marked as keyword-only. If a field is marked as keyword-only, then the only "
"effect is that the :meth:`~object.__init__` parameter generated from a "
"keyword-only field must be specified with a keyword when :meth:`!__init__` "
"is called. There is no effect on any other aspect of dataclasses. See the :"
"term:`parameter` glossary entry for details. Also see the :const:`KW_ONLY` "
"section."
msgstr ""
"*kw_only* : si vrai (``False`` est la valeur par défaut) alors tous les "
"champs sont marqués comme exclusivement nommés. Si un champ est marqué comme "
"exclusivement nommé, le seul impact est que le champ de la méthode :meth:"
"`__init__` générée devra être explicitement nommé lors de l'appel de la "
"méthode :meth:`__init__`. Il n'y a aucun autre effet dans les autres aspects "
"des classes de données. Voir l'entrée :term:`paramètre <parameter>` du "
"glossaire pour plus d'informations. Voir également la section :const:"
"`KW_ONLY`."
#: library/dataclasses.rst:185
#, fuzzy
msgid ""
"*slots*: If true (the default is ``False``), :attr:`~object.__slots__` "
"attribute will be generated and new class will be returned instead of the "
"original one. If :attr:`!__slots__` is already defined in the class, then :"
"exc:`TypeError` is raised."
msgstr ""
"*slot* : si vrai (``False`` est la valeur par défaut), l'attribut :attr:"
"`__slots__` est généré et une nouvelle classe est renvoyée à la place de "
"celle d'origine. Si :attr:`__slots__` est déjà défini dans la classe alors "
"une :exc:`TypeError` est levée."
#: library/dataclasses.rst:191
msgid ""
"Calling no-arg :func:`super` in dataclasses using ``slots=True`` will result "
"in the following exception being raised: ``TypeError: super(type, obj): obj "
"must be an instance or subtype of type``. The two-arg :func:`super` is a "
"valid workaround. See :gh:`90562` for full details."
msgstr ""
#: library/dataclasses.rst:198
msgid ""
"Passing parameters to a base class :meth:`~object.__init_subclass__` when "
"using ``slots=True`` will result in a :exc:`TypeError`. Either use "
"``__init_subclass__`` with no parameters or use default values as a "
"workaround. See :gh:`91126` for full details."
msgstr ""
#: library/dataclasses.rst:206
#, fuzzy
msgid ""
"If a field name is already included in the :attr:`!__slots__` of a base "
"class, it will not be included in the generated :attr:`!__slots__` to "
"prevent :ref:`overriding them <datamodel-note-slots>`. Therefore, do not "
"use :attr:`!__slots__` to retrieve the field names of a dataclass. Use :func:"
"`fields` instead. To be able to determine inherited slots, base class :attr:"
"`!__slots__` may be any iterable, but *not* an iterator."
msgstr ""
"Si un nom de champ est déjà inclus dans le ``__slots__`` d'une classe mère, "
"il n'est pas inclus dans les ``__slots__`` générés pour éviter de :ref:`les "
"remplacer <datamodel-note-slots>`. Par conséquent, n'utilisez pas "
"``__slots__`` pour récupérer les noms de champ d'une classe de données. "
"Utilisez :func:`fields` à la place. Pour pouvoir déterminer les *slots* "
"hérités, ``__slots__`` de la classe mère peut être n'importe quel itérable, "
"mais *pas* un itérateur."
#: library/dataclasses.rst:216
#, fuzzy
msgid ""
"*weakref_slot*: If true (the default is ``False``), add a slot named "
"\"__weakref__\", which is required to make an instance :func:`weakref-able "
"<weakref.ref>`. It is an error to specify ``weakref_slot=True`` without also "
"specifying ``slots=True``."
msgstr ""
"``weakref_slot`` : s'il est vrai (la valeur par défaut est ``False``), "
"ajoute un *slot* nommé ``\"__weakref__\"``, ce qui est nécessaire pour "
"pouvoir référencer faiblement une instance. C'est une erreur de spécifier "
"``weakref_slot=True`` sans spécifier également ``slots=True``."
#: library/dataclasses.rst:224
msgid ""
"``field``\\s may optionally specify a default value, using normal Python "
"syntax::"
msgstr ""
"Les champs peuvent éventuellement préciser une valeur par défaut, en "
"utilisant la syntaxe Python normale ::"
#: library/dataclasses.rst:227
msgid ""
"@dataclass\n"
"class C:\n"
" a: int # 'a' has no default value\n"
" b: int = 0 # assign a default value for 'b'"
msgstr ""
#: library/dataclasses.rst:232
#, fuzzy
msgid ""
"In this example, both :attr:`!a` and :attr:`!b` will be included in the "
"added :meth:`~object.__init__` method, which will be defined as::"
msgstr ""
"Dans cet exemple, ``a`` et ``b`` sont tous deux inclus dans la signature de "
"la méthode générée :meth:`__init__`, qui est définie comme suit ::"
#: library/dataclasses.rst:235
msgid "def __init__(self, a: int, b: int = 0):"
msgstr ""
#: library/dataclasses.rst:237
msgid ""
":exc:`TypeError` will be raised if a field without a default value follows a "
"field with a default value. This is true whether this occurs in a single "
"class, or as a result of class inheritance."
msgstr ""
"Une :exc:`TypeError` est levée si un champ sans valeur par défaut est défini "
"après un champ avec une valeur par défaut. C’est le cas que ce soit dans "
"une seule classe ou si c’est le résultat d’un héritage de classes."
#: library/dataclasses.rst:243
#, fuzzy
msgid ""
"For common and simple use cases, no other functionality is required. There "
"are, however, some dataclass features that require additional per-field "
"information. To satisfy this need for additional information, you can "
"replace the default field value with a call to the provided :func:`!field` "
"function. For example::"
msgstr ""
"Dans les cas les plus simples et courants, ce qui a été décrit jusqu'ici "
"suffit. Cependant, les classes de données possèdent des fonctionnalités "
"supplémentaires fondées sur des métadonnées propres à chaque champ. Pour "
"remplir ces métadonnées, il suffit de mettre un appel à la fonction :func:"
"`field` à la place de la valeur par défaut, comme dans cet exemple ::"
#: library/dataclasses.rst:249
msgid ""
"@dataclass\n"
"class C:\n"
" mylist: list[int] = field(default_factory=list)\n"
"\n"
"c = C()\n"
"c.mylist += [1, 2, 3]"
msgstr ""
#: library/dataclasses.rst:256
msgid ""
"As shown above, the :const:`MISSING` value is a sentinel object used to "
"detect if some parameters are provided by the user. This sentinel is used "
"because ``None`` is a valid value for some parameters with a distinct "
"meaning. No code should directly use the :const:`MISSING` value."
msgstr ""
"Comme le montre la signature, la constante :const:`MISSING` est une valeur "
"sentinelle pour déterminer si des paramètres ont été fournis par "
"l'utilisateur. ``None`` ne conviendrait pas puisque c'est une valeur avec un "
"sens qui peut être différent pour certains paramètres. La sentinelle :const:"
"`MISSING` est interne au module et ne doit pas être utilisée dans vos "
"programmes."
#: library/dataclasses.rst:261
#, fuzzy
msgid "The parameters to :func:`!field` are:"
msgstr "Les paramètres de :func:`field` sont :"
#: library/dataclasses.rst:263
#, fuzzy
msgid ""
"*default*: If provided, this will be the default value for this field. This "
"is needed because the :func:`!field` call itself replaces the normal "
"position of the default value."
msgstr ""
"*default* : s'il est fourni, il devient la valeur par défaut du champ. "
"L'appel à :meth:`field` est mis à la place normale de la valeur par défaut, "
"d'où la nécessité de ce paramètre."
#: library/dataclasses.rst:267
#, fuzzy
msgid ""
"*default_factory*: If provided, it must be a zero-argument callable that "
"will be called when a default value is needed for this field. Among other "
"purposes, this can be used to specify fields with mutable default values, as "
"discussed below. It is an error to specify both *default* and "
"*default_factory*."
msgstr ""
"*default_factory* : s'il est fourni, ce doit être un objet appelable sans "
"argument. Il est alors appelé à chaque fois qu'il faut une valeur par défaut "
"pour le champ. Ceci permet, entre autres choses, de définir des champs dont "
"les valeurs par défaut sont mutables. Une erreur se produit si *default* et "
"*default_factory* sont donnés tous les deux."
#: library/dataclasses.rst:273
#, fuzzy
msgid ""
"*init*: If true (the default), this field is included as a parameter to the "
"generated :meth:`~object.__init__` method."
msgstr ""
"*init* : si vrai (par défaut), la méthode :meth:`__init__` générée possède "
"un paramètre correspondant à ce champ."
#: library/dataclasses.rst:276
#, fuzzy
msgid ""
"*repr*: If true (the default), this field is included in the string returned "
"by the generated :meth:`~object.__repr__` method."
msgstr ""
"*repr* : si vrai (par défaut), le champ est inclus dans les chaînes "
"construites par la méthode :meth:`__repr__` générée."
#: library/dataclasses.rst:279
#, fuzzy
msgid ""
"*hash*: This can be a bool or ``None``. If true, this field is included in "
"the generated :meth:`~object.__hash__` method. If ``None`` (the default), "
"use the value of *compare*: this would normally be the expected behavior. A "
"field should be considered in the hash if it's used for comparisons. "
"Setting this value to anything other than ``None`` is discouraged."
msgstr ""
"*hash* : ce paramètre est un booléen ou ``None``. La valeur ``False`` force "
"la prise en compte du champ dans la méthode :meth:`__hash__` générée, alors "
"que ``False`` force son exclusion. ``None`` revient à mettre la même valeur "
"que *compare*, ce qui est en général correct : il faut inclure dans le "
"hachage les champs employés pour les comparaisons. Il est déconseillé de "
"mettre ce paramètre à autre chose que ``None``."
#: library/dataclasses.rst:286
msgid ""
"One possible reason to set ``hash=False`` but ``compare=True`` would be if a "
"field is expensive to compute a hash value for, that field is needed for "
"equality testing, and there are other fields that contribute to the type's "
"hash value. Even if a field is excluded from the hash, it will still be "
"used for comparisons."
msgstr ""
"Cependant, une raison légitime de mettre *hash* à ``False`` alors que "
"*compare* est à ``True`` est la concourance de trois facteurs : le champ est "
"coûteux à hacher ; il est nécessaire pour les comparaisons d'égalité ; et il "
"y a déjà d'autres champs qui participent au hachage des instances. À ce "
"moment, on peut alors se passer du champ dans le hachage tout en le faisant "
"participer aux comparaisons."
#: library/dataclasses.rst:292
#, fuzzy
msgid ""
"*compare*: If true (the default), this field is included in the generated "
"equality and comparison methods (:meth:`~object.__eq__`, :meth:`~object."
"__gt__`, et al.)."
msgstr ""
"*compare* : si vrai (par défaut), le champ est considéré dans les "
"comparaisons d'égalité et d'inégalité dans les méthodes générées :meth:"
"`__eq__`, :meth:`__gt__`, etc."
#: library/dataclasses.rst:296
#, fuzzy
msgid ""
"*metadata*: This can be a mapping or ``None``. ``None`` is treated as an "
"empty dict. This value is wrapped in :func:`~types.MappingProxyType` to "
"make it read-only, and exposed on the :class:`Field` object. It is not used "
"at all by Data Classes, and is provided as a third-party extension "
"mechanism. Multiple third-parties can each have their own key, to use as a "
"namespace in the metadata."
msgstr ""
"*metadata* : ce paramètre est un tableau associatif (*mapping* en anglais). "
"La valeur par défaut de ``None`` est prise comme un dictionnaire vide. Le "
"tableau associatif devient accessible sur l'objet :class:`Field`, sous la "
"forme d'un :func:`~types.MappingProxyType` afin qu'il soit en lecture seule."
#: library/dataclasses.rst:304
#, fuzzy
msgid ""
"*kw_only*: If true, this field will be marked as keyword-only. This is used "
"when the generated :meth:`~object.__init__` method's parameters are computed."
msgstr ""
"``kw_only`` : s'il est vrai, ce champ est marqué comme exclusivement nommé. "
"Cela est utilisé lors du traitement des paramètres de la méthode :meth:"
"`__init__` générée."
#: library/dataclasses.rst:310
#, fuzzy
msgid ""
"If the default value of a field is specified by a call to :func:`!field`, "
"then the class attribute for this field will be replaced by the specified "
"*default* value. If *default* is not provided, then the class attribute "
"will be deleted. The intent is that after the :func:`@dataclass "
"<dataclass>` decorator runs, the class attributes will all contain the "
"default values for the fields, just as if the default value itself were "
"specified. For example, after::"
msgstr ""
"Si la valeur par défaut d'un champ est donnée dans un appel à :func:`field` "
"(et pas directement), l'attribut correspondant de la classe est remplacé par "
"cette valeur. Si le paramètre *default* n'est pas passé, l'attribut est "
"simplement supprimé. De cette manière, après le passage du décorateur :func:"
"`dataclass`, les attributs de la classe contiennent les valeurs par défaut "
"des champs exactement comme si elles avaient été définies directement. Par "
"exemple ::"
#: library/dataclasses.rst:319
msgid ""
"@dataclass\n"
"class C:\n"
" x: int\n"
" y: int = field(repr=False)\n"
" z: int = field(repr=False, default=10)\n"
" t: int = 20"
msgstr ""
#: library/dataclasses.rst:326
#, fuzzy
msgid ""
"The class attribute :attr:`!C.z` will be ``10``, the class attribute :attr:`!"
"C.t` will be ``20``, and the class attributes :attr:`!C.x` and :attr:`!C.y` "
"will not be set."
msgstr ""
"Après l'exécution de ce code, l'attribut de classe ``C.z`` vaut ``10`` et "
"l'attribut ``C.t`` vaut ``20``, alors que les attributs ``C.x`` et ``C.y`` "
"n'existent pas."
#: library/dataclasses.rst:332
#, fuzzy
msgid ""
":class:`!Field` objects describe each defined field. These objects are "
"created internally, and are returned by the :func:`fields` module-level "
"method (see below). Users should never instantiate a :class:`!Field` object "
"directly. Its documented attributes are:"
msgstr ""
"Les objets :class:`Field` contiennent des informations sur les champs. Ils "
"sont créés en interne, et on y accède à l'aide de la méthode au niveau du "
"module :func:`fields` (voir plus bas). Les utilisateurs ne doivent jamais "
"instancier un objet :class:`Field` eux-mêmes. Les attributs documentés sont "
"les suivants :"
#: library/dataclasses.rst:337
#, fuzzy
msgid ":attr:`!name`: The name of the field."
msgstr "*name* : le nom du champ ;"
#: library/dataclasses.rst:338
#, fuzzy
msgid ":attr:`!type`: The type of the field."
msgstr "*type* : le type associé au champ par l'annotation ;"
#: library/dataclasses.rst:339
#, fuzzy
msgid ""
":attr:`!default`, :attr:`!default_factory`, :attr:`!init`, :attr:`!repr`, :"
"attr:`!hash`, :attr:`!compare`, :attr:`!metadata`, and :attr:`!kw_only` have "
"the identical meaning and values as they do in the :func:`field` function."
msgstr ""
"``default``, ``default_factory``, ``init``, ``repr``, ``hash``, ``compare``, "
"``metadata`` et ``kw_only`` qui correspondent aux paramètres de :func:"
"`field` et en prennent les valeurs."
#: library/dataclasses.rst:343
msgid ""
"Other attributes may exist, but they are private and must not be inspected "
"or relied on."
msgstr ""
"D'autres attributs peuvent exister, mais ils sont privés et ne sont pas "
"censés être inspectés. Le code ne doit jamais reposer sur eux."
#: library/dataclasses.rst:348
msgid ""
"Returns a tuple of :class:`Field` objects that define the fields for this "
"dataclass. Accepts either a dataclass, or an instance of a dataclass. "
"Raises :exc:`TypeError` if not passed a dataclass or instance of one. Does "
"not return pseudo-fields which are ``ClassVar`` or ``InitVar``."
msgstr ""
"Renvoie un *n*-uplet d'objets :class:`Field` correspondant aux champs de "
"l'argument, à l'exclusion des pseudo-champs ``ClassVar`` ou ``InitVar``. "
"L'argument peut être soit une classe de données, soit une instance d'une "
"telle classe ; si ce n'est pas le cas, une exception :exc:`TypeError` est "
"levée."
#: library/dataclasses.rst:355
#, fuzzy
msgid ""
"Converts the dataclass *obj* to a dict (by using the factory function "
"*dict_factory*). Each dataclass is converted to a dict of its fields, as "
"``name: value`` pairs. dataclasses, dicts, lists, and tuples are recursed "
"into. Other objects are copied with :func:`copy.deepcopy`."
msgstr ""
"Convertit la classe de données ``obj`` en un dictionnaire (en utilisant la "
"fonction ``dict_factory``). Les clés et valeurs proviennent directement des "
"champs. Les dictionnaires, listes, *n*-uplets et instances de classes de "
"données sont parcourus récursivement. Les autres objets sont copiés avec :"
"func:`copy.deepcopy`."
#: library/dataclasses.rst:361
#, fuzzy
msgid "Example of using :func:`!asdict` on nested dataclasses::"
msgstr ""
"Exemple d'utilisation de :func:`asdict` sur des classes de données "
"imbriquées ::"
#: library/dataclasses.rst:363
msgid ""
"@dataclass\n"
"class Point:\n"
" x: int\n"
" y: int\n"
"\n"
"@dataclass\n"
"class C:\n"
" mylist: list[Point]\n"
"\n"
"p = Point(10, 20)\n"
"assert asdict(p) == {'x': 10, 'y': 20}\n"
"\n"
"c = C([Point(0, 0), Point(10, 4)])\n"
"assert asdict(c) == {'mylist': [{'x': 0, 'y': 0}, {'x': 10, 'y': 4}]}"
msgstr ""
#: library/dataclasses.rst:398
msgid "To create a shallow copy, the following workaround may be used::"
msgstr ""
"Pour créer une copie superficielle, la solution de contournement suivante "
"peut être utilisée ::"
#: library/dataclasses.rst:380
msgid "{field.name: getattr(obj, field.name) for field in fields(obj)}"
msgstr ""
#: library/dataclasses.rst:382
#, fuzzy
msgid ""
":func:`!asdict` raises :exc:`TypeError` if *obj* is not a dataclass instance."
msgstr ""
":func:`asdict` lève :exc:`TypeError` si ``obj`` n'est pas une instance d'une "
"classe de données."
#: library/dataclasses.rst:387
#, fuzzy
msgid ""
"Converts the dataclass *obj* to a tuple (by using the factory function "
"*tuple_factory*). Each dataclass is converted to a tuple of its field "
"values. dataclasses, dicts, lists, and tuples are recursed into. Other "
"objects are copied with :func:`copy.deepcopy`."
msgstr ""
"Convertit l'instance d'une classe de données ``obj`` en un *n*-uplet (en "
"utilisant la fonction ``tuple_factory``). Chaque classe de données est "
"convertie vers un *n*-uplet des valeurs de ses champs. Cette fonction agit "
"récursivement sur les dictionnaires, listes et *n*-uplets. Les autres objets "
"sont copiés avec :func:`copy.deepcopy`."
#: library/dataclasses.rst:393
msgid "Continuing from the previous example::"
msgstr "Pour continuer l'exemple précédent ::"
#: library/dataclasses.rst:395
msgid ""
"assert astuple(p) == (10, 20)\n"
"assert astuple(c) == ([(0, 0), (10, 4)],)"
msgstr ""
#: library/dataclasses.rst:400
msgid "tuple(getattr(obj, field.name) for field in dataclasses.fields(obj))"
msgstr ""
#: library/dataclasses.rst:402
#, fuzzy
msgid ""
":func:`!astuple` raises :exc:`TypeError` if *obj* is not a dataclass "
"instance."
msgstr ""
":func:`astuple` lève :exc:`TypeError` si ``obj`` n'est pas une instance "
"d'une classe de données."
#: library/dataclasses.rst:407
#, fuzzy
msgid ""
"Creates a new dataclass with name *cls_name*, fields as defined in *fields*, "
"base classes as given in *bases*, and initialized with a namespace as given "
"in *namespace*. *fields* is an iterable whose elements are each either "
"``name``, ``(name, type)``, or ``(name, type, Field)``. If just ``name`` is "
"supplied, :data:`typing.Any` is used for ``type``. The values of *init*, "
"*repr*, *eq*, *order*, *unsafe_hash*, *frozen*, *match_args*, *kw_only*, "
"*slots*, and *weakref_slot* have the same meaning as they do in :func:"
"`@dataclass <dataclass>`."
msgstr ""
"Crée une nouvelle classe de données avec le nom ``cls_name``. Les champs "
"proviennent de ``fields``. Les classes mères sont lues dans ``bases``. "
"L'espace de nommage de la classe est initialisé par ``namespace``. "
"``fields`` est un itérable dont les éléments sont individuellement de la "
"forme ``name``, ``(name:type)`` ou ``(name, type, Field)``. Si seul ``name`` "
"est fourni, ``typing.Any`` est utilisé pour ``type``. Les valeurs de "
"``init``, ``repr``, ``eq``, ``order``, ``unsafe_hash``, ``frozen``, "
"``match_args``, ``kw_only``, ``slots`` et ``weakref_slot`` ont la même "
"signification que dans :func:`dataclass`."
#: library/dataclasses.rst:417
msgid ""
"If *module* is defined, the :attr:`!__module__` attribute of the dataclass "
"is set to that value. By default, it is set to the module name of the caller."
msgstr ""
#: library/dataclasses.rst:421
#, fuzzy
msgid ""
"This function is not strictly required, because any Python mechanism for "
"creating a new class with :attr:`!__annotations__` can then apply the :func:"
"`@dataclass <dataclass>` function to convert that class to a dataclass. "
"This function is provided as a convenience. For example::"
msgstr ""
"Cette fonction est pratique mais pas absolument nécessaire, puisqu'il suffit "
"de créer par un moyen quelconque une classe avec l'attribut "
"``__annotation__`` et de lui appliquer la fonction :func:`dataclass`, qui la "
"convertit en une classe de données. Par exemple, ceci ::"
#: library/dataclasses.rst:427
msgid ""
"C = make_dataclass('C',\n"
" [('x', int),\n"
" 'y',\n"
" ('z', int, field(default=5))],\n"
" namespace={'add_one': lambda self: self.x + 1})"
msgstr ""
#: library/dataclasses.rst:433
msgid "Is equivalent to::"
msgstr "est équivalent à ::"
#: library/dataclasses.rst:435
msgid ""
"@dataclass\n"
"class C:\n"
" x: int\n"
" y: 'typing.Any'\n"
" z: int = 5\n"
"\n"
" def add_one(self):\n"
" return self.x + 1"
msgstr ""
#: library/dataclasses.rst:446
#, fuzzy
msgid ""
"Creates a new object of the same type as *obj*, replacing fields with values "
"from *changes*. If *obj* is not a Data Class, raises :exc:`TypeError`. If "
"keys in *changes* are not field names of the given dataclass, raises :exc:"
"`TypeError`."
msgstr ""
"Crée un nouvel objet du même type que ``obj`` en affectant aux champs les "
"valeurs données par ``changes``. Si ``obj`` n'est pas une classe de "
"données, :exc:`TypeError` est levée. Si une clé dans ``changes`` ne "
"correspond à aucun champ de l'instance, :exc:`TypeError` est levée."
#: library/dataclasses.rst:451
#, fuzzy
msgid ""
"The newly returned object is created by calling the :meth:`~object.__init__` "
"method of the dataclass. This ensures that :meth:`__post_init__`, if "
"present, is also called."
msgstr ""
"L'objet renvoyé est créé à l'aide de la méthode :meth:`__init__` de la "
"classe de données, ce qui garantit que :meth:`__post_init__` est appelée (si "
"elle existe)."
#: library/dataclasses.rst:455
#, fuzzy
msgid ""
"Init-only variables without default values, if any exist, must be specified "
"on the call to :func:`!replace` so that they can be passed to :meth:`!"
"__init__` and :meth:`__post_init__`."
msgstr ""
"Si un champ d'initialisation (voir plus bas) n'a pas de valeur par défaut, "
"il faut l'inclure dans l'appel à :func:`replace` afin qu'il soit passé à :"
"meth:`__init__` et :meth:`__post_init__`."
#: library/dataclasses.rst:459
#, fuzzy
msgid ""
"It is an error for *changes* to contain any fields that are defined as "
"having ``init=False``. A :exc:`ValueError` will be raised in this case."
msgstr ""
"Si une clé de *changes* correspond à un champ défini avec ``init=False``, :"
"exc:`ValueError` est levée."
#: library/dataclasses.rst:463
#, fuzzy
msgid ""
"Be forewarned about how ``init=False`` fields work during a call to :func:`!"
"replace`. They are not copied from the source object, but rather are "
"initialized in :meth:`__post_init__`, if they're initialized at all. It is "
"expected that ``init=False`` fields will be rarely and judiciously used. If "
"they are used, it might be wise to have alternate class constructors, or "
"perhaps a custom :func:`!replace` (or similarly named) method which handles "
"instance copying."
msgstr ""
"Prenez garde aux champs définis avec ``init=False`` dans un appel à :func:"
"`replace`. Ils ne sont pas copiés automatiquement de l'instance source. "
"C'est le rôle de :meth:`__post_init__` de les initialiser — ou pas. Les "
"champs avec ``init=False`` doivent rarement être utilisés et seulement à bon "
"escient. Si vous en avez, il peut être sage de traiter la copie des "
"instances par des constructeurs de classe alternatifs, ou bien une méthode "
"personnalisée ``replace()`` (ou un nom similaire)."
#: library/dataclasses.rst:474
#, fuzzy
msgid ""
"Return ``True`` if its parameter is a dataclass (including subclasses of a "
"dataclass) or an instance of one, otherwise return ``False``."
msgstr ""
"Renvoie ``True`` si l'argument est soit une classe de données, soit une "
"instance d'une telle classe. Sinon, renvoie ``False``."
#: library/dataclasses.rst:477
msgid ""
"If you need to know if a class is an instance of a dataclass (and not a "
"dataclass itself), then add a further check for ``not isinstance(obj, "
"type)``::"
msgstr ""
"Pour vérifier qu'un objet *obj* est une instance d'une classe de données, et "
"non pas lui-même une classe de données, ajoutez le test ``not "
"isinstance(obj, type)`` ::"
#: library/dataclasses.rst:481
msgid ""
"def is_dataclass_instance(obj):\n"
" return is_dataclass(obj) and not isinstance(obj, type)"
msgstr ""