robotcode-analyze 0.91.0__tar.gz → 0.92.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robotcode-analyze
3
- Version: 0.91.0
3
+ Version: 0.92.0
4
4
  Summary: RobotCode analyze plugin for Robot Framework
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -25,9 +25,9 @@ Classifier: Programming Language :: Python :: Implementation :: PyPy
25
25
  Classifier: Topic :: Utilities
26
26
  Classifier: Typing :: Typed
27
27
  Requires-Python: >=3.8
28
- Requires-Dist: robotcode-plugin==0.91.0
29
- Requires-Dist: robotcode-robot==0.91.0
30
- Requires-Dist: robotcode==0.91.0
28
+ Requires-Dist: robotcode-plugin==0.92.0
29
+ Requires-Dist: robotcode-robot==0.92.0
30
+ Requires-Dist: robotcode==0.92.0
31
31
  Requires-Dist: robotframework>=4.1.0
32
32
  Description-Content-Type: text/markdown
33
33
 
@@ -27,9 +27,9 @@ classifiers = [
27
27
  ]
28
28
  dependencies = [
29
29
  "robotframework>=4.1.0",
30
- "robotcode-plugin==0.91.0",
31
- "robotcode-robot==0.91.0",
32
- "robotcode==0.91.0",
30
+ "robotcode-plugin==0.92.0",
31
+ "robotcode-robot==0.92.0",
32
+ "robotcode==0.92.0",
33
33
  ]
34
34
  dynamic = ["version"]
35
35
 
@@ -0,0 +1 @@
1
+ __version__ = "0.92.0"
@@ -2,13 +2,13 @@ from pathlib import Path
2
2
 
3
3
  from robotcode.robot.config.model import RobotConfig
4
4
 
5
- from .config import AnalyzerConfig
5
+ from .config import AnalyzeConfig
6
6
 
7
7
 
8
8
  class Analyzer:
9
9
  def __init__(
10
10
  self,
11
- config: AnalyzerConfig,
11
+ config: AnalyzeConfig,
12
12
  robot_config: RobotConfig,
13
13
  root_folder: Path,
14
14
  ):
@@ -2,10 +2,9 @@ from typing import Tuple, Union
2
2
 
3
3
  import click
4
4
 
5
- from robotcode.analyze.config import AnalyzerConfig
5
+ from robotcode.analyze.config import AnalyzeConfig
6
6
  from robotcode.plugin import Application, pass_application
7
7
  from robotcode.robot.config.loader import (
8
- load_config_from_path,
9
8
  load_robot_config_from_path,
10
9
  )
11
10
  from robotcode.robot.config.utils import get_config_files
@@ -30,21 +29,20 @@ def analyze(app: Application, paths: Tuple[str]) -> Union[str, int, None]:
30
29
  config_files, root_folder, _ = get_config_files(paths, app.config.config_files, verbose_callback=app.verbose)
31
30
 
32
31
  try:
33
- robot_config = (
34
- load_robot_config_from_path(*config_files)
35
- .combine_profiles(*(app.config.profiles or []), verbose_callback=app.verbose, error_callback=app.error)
36
- .evaluated_with_env()
32
+ robot_config = load_robot_config_from_path(
33
+ *config_files, extra_tools={"robotcode-analyze": AnalyzeConfig}, verbose_callback=app.verbose
37
34
  )
38
35
 
39
- analyzer_config = load_config_from_path(
40
- AnalyzerConfig,
41
- *config_files,
42
- tool_name="robotcode-analyze",
43
- robot_toml_tool_name="robotcode-analyze",
44
- ).evaluated()
36
+ analyzer_config = robot_config.tool.get("robotcode-analyze", None) if robot_config.tool is not None else None
37
+ if analyzer_config is None:
38
+ analyzer_config = AnalyzeConfig()
39
+
40
+ robot_profile = robot_config.combine_profiles(
41
+ *(app.config.profiles or []), verbose_callback=app.verbose, error_callback=app.error
42
+ ).evaluated_with_env()
45
43
 
46
44
  app.print_data(analyzer_config)
47
- app.print_data(robot_config)
45
+ app.print_data(robot_profile)
48
46
 
49
47
  except (TypeError, ValueError) as e:
50
48
  raise click.ClickException(str(e)) from e
@@ -0,0 +1,248 @@
1
+ # ruff: noqa: RUF009
2
+ from dataclasses import dataclass
3
+ from typing import List, Optional
4
+
5
+ from robotcode.robot.config.model import BaseOptions, field
6
+
7
+
8
+ @dataclass
9
+ class ModifiersConfig(BaseOptions):
10
+ """Modifiers configuration."""
11
+
12
+ ignore: Optional[List[str]] = field(
13
+ description="""\
14
+ Specifies the error codes to ignore.
15
+
16
+ Examples:
17
+
18
+ ```toml
19
+ [tool.robotcode-analyze.modifiers]
20
+ ignore = ["VariableNotFound", "multiple-keywords"]
21
+ ```
22
+ """
23
+ )
24
+ extend_ignore: Optional[List[str]] = field(
25
+ description="""
26
+ Extend the error codes to ignore.
27
+
28
+ Examples:
29
+
30
+ ```toml
31
+ [tool.robotcode-analyze.modifiers]
32
+ extend_ignore = ["VariableNotFound", "multiple-keywords"]
33
+ ```
34
+ """
35
+ )
36
+ error: Optional[List[str]] = field(
37
+ description="""
38
+ Specifies the error codes to treat as errors.
39
+
40
+ Examples:
41
+
42
+ ```toml
43
+ [tool.robotcode-analyze.modifiers]
44
+ error = ["VariableNotFound", "multiple-keywords"]
45
+ ```
46
+ """
47
+ )
48
+ extend_error: Optional[List[str]] = field(
49
+ description="""
50
+ Extend the error codes to treat as errors.
51
+
52
+ Examples:
53
+
54
+ ```toml
55
+ [tool.robotcode-analyze.modifiers]
56
+ extend_error = ["VariableNotFound", "multiple-keywords"]
57
+ ```
58
+ """
59
+ )
60
+ warning: Optional[List[str]] = field(
61
+ description="""
62
+ Specifies the error codes to treat as warning.
63
+
64
+ Examples:
65
+
66
+ ```toml
67
+ [tool.robotcode-analyze.modifiers]
68
+ warning = ["VariableNotFound", "multiple-keywords"]
69
+ ```
70
+ """
71
+ )
72
+ extend_warning: Optional[List[str]] = field(
73
+ description="""
74
+ Extend the error codes to treat as warnings.
75
+
76
+ Examples:
77
+
78
+ ```toml
79
+ [tool.robotcode-analyze.modifiers]
80
+ extend_warning = ["VariableNotFound", "multiple-keywords"]
81
+ ```
82
+ """
83
+ )
84
+ information: Optional[List[str]] = field(
85
+ description="""
86
+ Specifies the error codes to treat as information.
87
+
88
+ Examples:
89
+
90
+ ```toml
91
+ [tool.robotcode-analyze.modifiers]
92
+ information = ["VariableNotFound", "multiple-keywords"]
93
+ ```
94
+ """
95
+ )
96
+ extend_information: Optional[List[str]] = field(
97
+ description="""
98
+ Extend the error codes to treat as information.
99
+
100
+ Examples:
101
+
102
+ ```toml
103
+ [tool.robotcode-analyze.modifiers]
104
+ extend_information = ["VariableNotFound", "multiple-keywords"]
105
+ ```
106
+ """
107
+ )
108
+ hint: Optional[List[str]] = field(
109
+ description="""
110
+ Specifies the error codes to treat as hint.
111
+
112
+ Examples:
113
+
114
+ ```toml
115
+ [tool.robotcode-analyze.modifiers]
116
+ hint = ["VariableNotFound", "multiple-keywords"]
117
+ ```
118
+ """
119
+ )
120
+ extend_hint: Optional[List[str]] = field(
121
+ description="""
122
+ Extend the error codes to treat as hint.
123
+
124
+ Examples:
125
+
126
+ ```toml
127
+ [tool.robotcode-analyze.modifiers]
128
+ extend_hint = ["VariableNotFound", "multiple-keywords"]
129
+ ```
130
+ """
131
+ )
132
+
133
+
134
+ @dataclass
135
+ class CacheConfig(BaseOptions):
136
+ """Cache configuration."""
137
+
138
+ cache_dir: Optional[str] = field(description="Path to the cache directory.")
139
+
140
+ ignored_libraries: Optional[List[str]] = field(
141
+ description="""\
142
+ Specifies the library names that should not be cached.
143
+ This is useful if you have a dynamic or hybrid library that has different keywords depending on
144
+ the arguments. You can specify a glob pattern that matches the library name or the source file.
145
+
146
+ Examples:
147
+ - `**/mylibfolder/mylib.py`
148
+ - `MyLib`\n- `mylib.subpackage.subpackage`
149
+
150
+ For robot framework internal libraries, you have to specify the full module name like
151
+ `robot.libraries.Remote`.
152
+ """,
153
+ )
154
+ extend_ignored_libraries: Optional[List[str]] = field(description="Extend the ignored libraries setting.")
155
+
156
+ ignored_variables: Optional[List[str]] = field(
157
+ description="""\
158
+ Specifies the variable files that should not be cached.
159
+ This is useful if you have a dynamic or hybrid variable files that has different variables
160
+ depending on the arguments. You can specify a glob pattern that matches the variable module
161
+ name or the source file.
162
+
163
+ Examples:
164
+ - `**/variables/myvars.py`
165
+ - `MyVariables`
166
+ - `myvars.subpackage.subpackage`
167
+ """,
168
+ )
169
+ extend_ignored_variables: Optional[List[str]] = field(description="Extend the ignored variables setting.")
170
+
171
+ ignore_arguments_for_library: Optional[List[str]] = field(
172
+ description="""\
173
+ Specifies a list of libraries for which arguments will be ignored during analysis.
174
+ This is usefull if you have library that gets variables from a python file as arguments that contains
175
+ complex data like big dictionaries or complex objects that **RobotCode** can't handle.
176
+ You can specify a glob pattern that matches the library name or the source file.
177
+
178
+ Examples:
179
+ - `**/mylibfolder/mylib.py`
180
+ - `MyLib`\n- `mylib.subpackage.subpackage`
181
+
182
+ If you change this setting, you may need to run the command
183
+ `RobotCode: Clear Cache and Restart Language Servers`.
184
+
185
+ _Ensure your library functions correctly without arguments e.g. by defining default
186
+ values for all arguments._
187
+ """
188
+ )
189
+ extend_ignore_arguments_for_library: Optional[List[str]] = field(
190
+ description="Extend the ignore arguments for library settings."
191
+ )
192
+
193
+
194
+ @dataclass
195
+ class AnalyzeConfig(BaseOptions):
196
+ """robotcode-analyze configuration."""
197
+
198
+ modifiers: Optional[ModifiersConfig] = field(
199
+ description="""\
200
+ Defines the modifiers for the analysis.
201
+
202
+ Examples:
203
+
204
+ ```toml
205
+ [tool.robotcode-analyze.modifiers]
206
+ ignore = ["VariableNotFound"]
207
+ hint = ["KeywordNotFound"]
208
+ information = ["MultipleKeywords"]
209
+ ```
210
+ """
211
+ )
212
+ extend_modifiers: Optional[ModifiersConfig] = field(
213
+ description="""\
214
+ Extends the modifiers for the analysis.
215
+
216
+ Examples:
217
+
218
+ ```toml
219
+ [tool.robotcode-analyze.extend_modifiers]
220
+ ignore = ["VariableNotFound"]
221
+ extend-hint = ["KeywordNotFound"]
222
+ extend-information = ["MultipleKeywords"]
223
+ ```
224
+ """
225
+ )
226
+
227
+ cache: Optional[CacheConfig] = field(description="Defines the cache configuration.")
228
+ extend_cache: Optional[CacheConfig] = field(description="Extend the cache configuration.")
229
+
230
+ exclude_patterns: Optional[List[str]] = field(
231
+ description="Specifies glob patterns for excluding files and folders from analysing by the language server.",
232
+ )
233
+ extend_exclude_patterns: Optional[List[str]] = field(description="Extend the exclude patterns.")
234
+
235
+ global_library_search_order: Optional[List[str]] = field(
236
+ description="""\
237
+ Specifies a global [search order](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#specifying-explicit-priority-between-libraries-and-resources)
238
+ for libraries and resources.
239
+ This is usefull when you have libraries containing keywords with the same name. **RobotCode** is unable to
240
+ analyze the library search order in a file specified with
241
+ [`Set Library Search Order`](https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Library%20Search%20Order),
242
+ so you can define a global order here. Just make sure to call the `Set Library Search Order`
243
+ keyword somewhere in your robot file or internally in your library.
244
+ """,
245
+ )
246
+ extend_global_library_search_order: Optional[List[str]] = field(
247
+ description="Extend the global library search order setting."
248
+ )
@@ -0,0 +1,19 @@
1
+ from typing import List
2
+
3
+ import click
4
+
5
+ from robotcode.plugin import hookimpl
6
+ from robotcode.plugin.specs import ToolConfig
7
+
8
+ from .cli import analyze
9
+ from .config import AnalyzeConfig
10
+
11
+
12
+ @hookimpl
13
+ def register_cli_commands() -> List[click.Command]:
14
+ return [analyze]
15
+
16
+
17
+ @hookimpl
18
+ def register_tool_config_classes() -> List[ToolConfig]:
19
+ return [ToolConfig("robotcode-analyze", AnalyzeConfig)]
@@ -1 +0,0 @@
1
- __version__ = "0.91.0"
@@ -1,59 +0,0 @@
1
- # ruff: noqa: RUF009
2
- from dataclasses import dataclass
3
- from enum import Enum
4
- from typing import List, Optional
5
-
6
- from robotcode.robot.config.model import BaseOptions, field
7
-
8
-
9
- class CacheSaveLocation(Enum):
10
- WORKSPACE_FOLDER = "workspaceFolder"
11
- WORKSPACE_STORAGE = "workspaceStorage"
12
-
13
-
14
- @dataclass
15
- class AnalyzerConfig(BaseOptions):
16
- select: Optional[List[str]] = field(description="Selects which rules are run.")
17
- extend_select: Optional[List[str]] = field(description="Extends the rules which are run.")
18
- ignore: Optional[List[str]] = field(description="Defines which rules are ignored.")
19
- extend_ignore: Optional[List[str]] = field(description="Extends the rules which are ignored.")
20
- exclude_patterns: List[str] = field(default_factory=list)
21
-
22
- cache_dir: Optional[str] = field(description="Path to the cache directory.")
23
-
24
- ignored_libraries: List[str] = field(
25
- default_factory=list,
26
- description="""\
27
- Specifies the library names that should not be cached.
28
- This is useful if you have a dynamic or hybrid library that has different keywords depending on
29
- the arguments. You can specify a glob pattern that matches the library name or the source file.
30
-
31
- Examples:
32
- - `**/mylibfolder/mylib.py`
33
- - `MyLib`\n- `mylib.subpackage.subpackage`
34
-
35
- For robot framework internal libraries, you have to specify the full module name like
36
- `robot.libraries.Remote`.
37
- """,
38
- )
39
- ignored_variables: List[str] = field(
40
- default_factory=list,
41
- description="""\
42
- Specifies the variable files that should not be cached.
43
- This is useful if you have a dynamic or hybrid variable files that has different variables
44
- depending on the arguments. You can specify a glob pattern that matches the variable module
45
- name or the source file.
46
-
47
- Examples:
48
- - `**/variables/myvars.py`
49
- - `MyVariables`
50
- - `myvars.subpackage.subpackage`
51
- """,
52
- )
53
-
54
- global_library_search_order: List[str] = field(
55
- default_factory=list,
56
- description="""\
57
- TODO
58
- """,
59
- )
@@ -1,18 +0,0 @@
1
- from typing import Any, List, Tuple, Type
2
-
3
- import click
4
-
5
- from robotcode.plugin import hookimpl
6
-
7
- from .cli import analyze
8
- from .config import AnalyzerConfig
9
-
10
-
11
- @hookimpl
12
- def register_cli_commands() -> List[click.Command]:
13
- return [analyze]
14
-
15
-
16
- @hookimpl
17
- def register_config_classes() -> List[Tuple[str, Type[Any]]]:
18
- return [("tool.robotcode-analyze", AnalyzerConfig)]