Skip to content

Commit ee256ce

Browse files
committed
feat(config): added posibility to allow different tool configs to robot.toml.json schema
1 parent f226091 commit ee256ce

File tree

3 files changed

+152
-3
lines changed

3 files changed

+152
-3
lines changed

etc/robot.toml.json

+132
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,106 @@
66
}
77
],
88
"definitions": {
9+
"AnalyzerConfig": {
10+
"additionalProperties": false,
11+
"description": "Analyzer configuration.",
12+
"properties": {
13+
"cache-dir": {
14+
"default": null,
15+
"description": "Path to the cache directory.",
16+
"title": "Cache dir",
17+
"type": [
18+
"string",
19+
"null"
20+
]
21+
},
22+
"exclude-patterns": {
23+
"default": [],
24+
"items": {
25+
"type": "string"
26+
},
27+
"title": "Exclude patterns",
28+
"type": "array"
29+
},
30+
"extend-ignore": {
31+
"default": null,
32+
"description": "Extends the rules which are ignored.",
33+
"items": {
34+
"type": "string"
35+
},
36+
"title": "Extend ignore",
37+
"type": [
38+
"array",
39+
"null"
40+
]
41+
},
42+
"extend-select": {
43+
"default": null,
44+
"description": "Extends the rules which are run.",
45+
"items": {
46+
"type": "string"
47+
},
48+
"title": "Extend select",
49+
"type": [
50+
"array",
51+
"null"
52+
]
53+
},
54+
"global-library-search-order": {
55+
"default": [],
56+
"description": "TODO\n",
57+
"items": {
58+
"type": "string"
59+
},
60+
"title": "Global library search order",
61+
"type": "array"
62+
},
63+
"ignore": {
64+
"default": null,
65+
"description": "Defines which rules are ignored.",
66+
"items": {
67+
"type": "string"
68+
},
69+
"title": "Ignore",
70+
"type": [
71+
"array",
72+
"null"
73+
]
74+
},
75+
"ignored-libraries": {
76+
"default": [],
77+
"description": "Specifies the library names that should not be cached.\nThis is useful if you have a dynamic or hybrid library that has different keywords depending on\nthe arguments. You can specify a glob pattern that matches the library name or the source file.\n\nExamples:\n- `**/mylibfolder/mylib.py`\n- `MyLib`\n- `mylib.subpackage.subpackage`\n\nFor robot framework internal libraries, you have to specify the full module name like\n`robot.libraries.Remote`.\n",
78+
"items": {
79+
"type": "string"
80+
},
81+
"title": "Ignored libraries",
82+
"type": "array"
83+
},
84+
"ignored-variables": {
85+
"default": [],
86+
"description": "Specifies the variable files that should not be cached.\nThis is useful if you have a dynamic or hybrid variable files that has different variables\ndepending on the arguments. You can specify a glob pattern that matches the variable module\nname or the source file.\n\nExamples:\n- `**/variables/myvars.py`\n- `MyVariables`\n- `myvars.subpackage.subpackage`\n",
87+
"items": {
88+
"type": "string"
89+
},
90+
"title": "Ignored variables",
91+
"type": "array"
92+
},
93+
"select": {
94+
"default": null,
95+
"description": "Selects which rules are run.",
96+
"items": {
97+
"type": "string"
98+
},
99+
"title": "Select",
100+
"type": [
101+
"array",
102+
"null"
103+
]
104+
}
105+
},
106+
"title": "AnalyzerConfig",
107+
"type": "object"
108+
},
9109
"Condition": {
10110
"additionalProperties": false,
11111
"description": "Condition to evaluate.",
@@ -3114,6 +3214,17 @@
31143214
"title": "Timestamp outputs"
31153215
},
31163216
"tool": {
3217+
"anyOf": [
3218+
{
3219+
"$ref": "#/definitions/ToolConfig"
3220+
},
3221+
{
3222+
"type": "object"
3223+
},
3224+
{
3225+
"type": "null"
3226+
}
3227+
],
31173228
"default": null,
31183229
"description": "Tool configurations.",
31193230
"title": "Tool"
@@ -5393,6 +5504,27 @@
53935504
},
53945505
"title": "TestDocProfile",
53955506
"type": "object"
5507+
},
5508+
"ToolConfig": {
5509+
"additionalProperties": false,
5510+
"description": "ToolConfig(robotcode_analyze: Union[robotcode.analyze.config.AnalyzerConfig, NoneType] = None)",
5511+
"properties": {
5512+
"robotcode-analyze": {
5513+
"anyOf": [
5514+
{
5515+
"$ref": "#/definitions/AnalyzerConfig"
5516+
},
5517+
{
5518+
"type": "null"
5519+
}
5520+
],
5521+
"default": null,
5522+
"description": "Analyzer configuration.",
5523+
"title": "Robotcode analyze"
5524+
}
5525+
},
5526+
"title": "ToolConfig",
5527+
"type": "object"
53965528
}
53975529
},
53985530
"x-taplo-info": {

packages/analyze/src/robotcode/analyze/config.py

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ class CacheSaveLocation(Enum):
1313

1414
@dataclass
1515
class AnalyzerConfig(BaseOptions):
16+
"""Analyzer configuration."""
17+
1618
select: Optional[List[str]] = field(description="Selects which rules are run.")
1719
extend_select: Optional[List[str]] = field(description="Extends the rules which are run.")
1820
ignore: Optional[List[str]] = field(description="Defines which rules are ignored.")

scripts/create_robot_toml_json_schema.py

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
import json
22
import pathlib
33
import typing
4-
from dataclasses import fields, is_dataclass
5-
from typing import Any, Callable, Optional
4+
from dataclasses import dataclass, fields, is_dataclass
5+
from typing import Any, Callable, Dict, Optional, Union
66

77
import apischema
88

9-
from robotcode.robot.config.model import RobotConfig
9+
from robotcode.analyze.config import AnalyzerConfig
10+
from robotcode.robot.config.model import RobotConfig as OrigRobotConfig
11+
from robotcode.robot.config.model import field
12+
13+
14+
@dataclass
15+
class ToolConfig:
16+
robotcode_analyze: Optional[AnalyzerConfig] = field(description="Analyzer configuration.") # noqa: RUF009
17+
18+
19+
@dataclass
20+
class RobotConfig(OrigRobotConfig):
21+
tool: Union[ToolConfig, Dict[str, Any], None] = field(description="Tool configurations.") # noqa: RUF009
22+
23+
24+
RobotConfig.__doc__ = OrigRobotConfig.__doc__
1025

1126
if __name__ == "__main__":
1227

0 commit comments

Comments
 (0)