You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pyproject.toml
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
[tool.poetry]
2
2
name = "importspy"
3
-
version = "0.1.7"
3
+
version = "0.1.8"
4
4
description = "ImportSpy is a lightweight Python library that enables proactive control over how your code is used when imported by other modules or packages. It allows developers to define rules that importing modules must follow, ensuring proper use and preventing misuse or errors."
Copy file name to clipboardExpand all lines: src/importspy/models.py
+24-5Lines changed: 24 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -17,6 +17,8 @@ class ClassModel(BaseModel):
17
17
18
18
## Attributes:
19
19
- **name** (`Optional[str]`): The name of the class. This can be `None` if the class name is unavailable. Defaults to `None`.
20
+
- **class_attr* (`Optional[List[str]]`): A list of class attributes names that are expected to be present in the class. Defaults to an empty list.
21
+
- *instance_attr* (`Optional[List[str]]`): A list of class isntance attributes names that are expected to be present in the class. Defaults to an empty list.
20
22
- **methods** (`Optional[List[str]]`): A list of method names that are expected to be present in the class. Defaults to an empty list.
21
23
- **superclasses** (`Optional[List[str]]`): A list of names of the superclasses from which this class inherits. Defaults to an empty list.
22
24
@@ -32,6 +34,8 @@ class ClassModel(BaseModel):
32
34
and inherit from `BaseClass`. External modules importing your code can then be validated to follow this structure.
33
35
"""
34
36
name: Optional[str] =None
37
+
class_attr: Optional[List[str]] = []
38
+
instance_attr: Optional[List[str]] = []
35
39
methods: Optional[List[str]] = []
36
40
superclasses: Optional[List[str]] = []
37
41
@@ -47,6 +51,7 @@ class SpyModel(BaseModel):
47
51
## Attributes:
48
52
- **filename** (`Optional[str]`): The name of the module file. If the name is unavailable, it can be `None`. Defaults to `None`.
49
53
- **version** (`Optional[str]`): The expected version of the module. Defaults to `None` if the version is not available.
54
+
- **variables** (`Optional[List[str]]`): A list of variables names that are expected to be defined within the module. Defaults to an empty list.
50
55
- **functions** (`Optional[List[str]]`): A list of function names that are expected to be defined within the module. Defaults to an empty list.
51
56
- **classes** (`Optional[List[ClassModel]]`): A list of class definitions within the module, represented by `ClassModel`. Defaults to an empty list.
52
57
@@ -84,8 +89,9 @@ class SpyModel(BaseModel):
84
89
This will extract the necessary metadata from `my_module` and create a `SpyModel` instance that describes the module's
85
90
structure, which can then be compared to the expected structure defined by the developer.
0 commit comments