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: docs/dev/docstrings.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ Locale dependent:
47
47
48
48
If omitted, the generator is assumed to be locale-independent.
49
49
50
-
!!! note title="Not entirely strict"
50
+
!!! note "Not entirely strict"
51
51
To be honest, if the line below Locale dependent is not exactly `yes` it's treated as `no`. But it's best to follow the format strictly to avoid confusion.
# Invalid — POSITIONAL_OR_KEYWORD params with *args (var positional)
61
61
definvalid_gen(extra: str, *args) -> str: ...
62
62
63
-
# WHY ? Because the Semantic Validator for the DSL cannot currently handle this combination. It would require a more complex parsing logic to determine which arguments are meant for `*args` and which are actual positionals parameters, especially since the user can pass any number of values for `*args`. To keep things simple and unambiguous, we enforce this constraint.
64
63
```
64
+
WHY ? Because the Semantic Validator for the DSL cannot currently handle this combination. It would require a more complex parsing logic to determine which arguments are meant for `*args` and which are actual positionals parameters, especially since the user can pass any number of values for `*args`. To keep things simple and unambiguous, we enforce this constraint.
65
+
65
66
66
67
!!! note "About union types"
67
68
The current implementation of the docstring parser and the semantic validator does not support union types (e.g., `str | int`) in generator signatures. This will be updated in future updates. and no, even Any is not supported too.
To add a new generator, simply define a function in any non-private module under `copia.generators` and ensure it follows the constraints outlined above. The function will be automatically registered and available for use in the DSL.
74
75
75
-
first check if the module you want to add the generator to already exists. If it does, add your function there. If not, create a new module and add your function there.
76
+
-first check if the module you want to add the generator to already exists. If it does, add your function there. If not, create a new module and add your function there.
76
77
77
-
since the registry is built dynamically, you don't need to do anything else to make your generator available — just define it and it will be picked up when the module is imported.
78
+
-since the registry is built dynamically, you don't need to do anything else to make your generator available — just define it and it will be picked up when the module is imported.
78
79
79
-
to ensure your generator is properly documented, follow the docstring format outlined in the [docstrings guide](./docstrings.md). This will help users understand how to use your generator and what it does.
80
+
-to ensure your generator is properly documented, follow the docstring format outlined in the [docstrings guide](./docstrings.md). This will help users understand how to use your generator and what it does.
80
81
81
-
and to finish, simply run pytest tests/test_generators_discover.py to avoid any import warnings or errors related to your new generator. If you see an ImportWarning about overriding a generator, it means you have a naming conflict — either rename your generator or remove the conflicting one. If you see an error about `**kwargs` or invalid parameter combinations, adjust your function signature accordingly.
82
+
-and to finish, simply run pytest tests/test_generators_discover.py to avoid any import warnings or errors related to your new generator. If you see an ImportWarning about overriding a generator, it means you have a naming conflict — either rename your generator or remove the conflicting one. If you see an error about `**kwargs` or invalid parameter combinations, adjust your function signature accordingly.
82
83
83
84
> just keep in mind, the function signature is a direct interface to users, so keep it simple and intuitive. Avoid complex parameter combinations that could confuse users or make the generator difficult to use in the DSL. The goal is to provide a clear and straightforward way for users to generate data without having to worry about the underlying implementation details.
0 commit comments