1
1
# Test for https://github.com/pylint-dev/pylint/issues/10236
2
2
from collections .abc import Generator
3
+ from dataclasses import dataclass
3
4
4
5
5
6
class Component :
6
7
"""A component class."""
7
8
def __init__ (self , name : str ):
8
9
self .name = name
9
10
10
-
11
11
class AssociationContainer :
12
12
"""Type hints only - no ownership."""
13
- # Association: just type hints, no actual assignment
14
- components : list [Component ]
15
- component_dict : dict [int , Component ]
16
- components_set : set [Component ]
17
- lazy_components : Generator [Component ]
18
-
19
-
20
- class AggregationContainer :
21
- """Comprehensions using existing objects - aggregation."""
22
- def __init__ (self , existing_components : list [Component ]):
23
- # Aggregation: comprehensions using existing objects (not creating)
24
- self .components : list [Component ] = [comp for comp in existing_components ]
25
- self .component_dict : dict [str , Component ] = {f"key_{ i } " : comp for i , comp in enumerate (existing_components )}
26
- self .components_set : set [Component ] = {comp for comp in existing_components }
27
- self .lazy_components : Generator [Component ] = (comp for comp in existing_components )
28
-
13
+ def __init__ (self ):
14
+ # Association: just type hints, no actual assignment
15
+ self .components : list [Component ]
16
+ self .component_dict : dict [int , Component ]
17
+ self .components_set : set [Component ]
18
+ self .lazy_components : Generator [Component ]
29
19
30
20
class CompositionContainer :
31
21
"""Comprehensions creating new objects - composition."""
@@ -34,4 +24,4 @@ def __init__(self):
34
24
self .components : list [Component ] = [Component (f"component_{ i } " ) for i in range (3 )]
35
25
self .component_dict : dict [int , Component ] = {i : Component (f"dict_component_{ i } " ) for i in range (2 )}
36
26
self .components_set : set [Component ] = {Component (f"set_component_{ i } " ) for i in range (2 )}
37
- self .lazy_components : Generator [Component ] = (Component (f"lazy_{ i } " ) for i in range (2 ))
27
+ self .lazy_components : Generator [Component ] = (Component (f"lazy_{ i } " ) for i in range (2 ))
0 commit comments