robotcode-robot 0.96.0__tar.gz → 0.97.0__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/PKG-INFO +2 -3
  2. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/pyproject.toml +1 -1
  3. robotcode_robot-0.97.0/src/robotcode/robot/__version__.py +1 -0
  4. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/config/loader.py +29 -7
  5. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/imports_manager.py +60 -6
  6. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/workspace_config.py +1 -0
  7. robotcode_robot-0.96.0/src/robotcode/robot/__version__.py +0 -1
  8. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/.gitignore +0 -0
  9. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/LICENSE.txt +0 -0
  10. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/README.md +0 -0
  11. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/__init__.py +0 -0
  12. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/config/__init__.py +0 -0
  13. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/config/model.py +0 -0
  14. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/config/utils.py +0 -0
  15. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/__init__.py +0 -0
  16. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/data_cache.py +0 -0
  17. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/diagnostics_modifier.py +0 -0
  18. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/document_cache_helper.py +0 -0
  19. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/entities.py +0 -0
  20. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/errors.py +0 -0
  21. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/keyword_finder.py +0 -0
  22. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/library_doc.py +0 -0
  23. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/model_helper.py +0 -0
  24. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/namespace.py +0 -0
  25. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/diagnostics/namespace_analyzer.py +0 -0
  26. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/py.typed +0 -0
  27. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/__init__.py +0 -0
  28. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/ast.py +0 -0
  29. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/markdownformatter.py +0 -0
  30. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/match.py +0 -0
  31. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/robot_path.py +0 -0
  32. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/stubs.py +0 -0
  33. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/variables.py +0 -0
  34. {robotcode_robot-0.96.0 → robotcode_robot-0.97.0}/src/robotcode/robot/utils/visitor.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: robotcode-robot
3
- Version: 0.96.0
3
+ Version: 0.97.0
4
4
  Summary: Support classes for RobotCode for handling Robot Framework projects.
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -10,7 +10,6 @@ Project-URL: Issues, https://github.com/robotcodedev/robotcode/issues
10
10
  Project-URL: Source, https://github.com/robotcodedev/robotcode
11
11
  Author-email: Daniel Biehl <dbiehl@live.de>
12
12
  License: Apache-2.0
13
- License-File: LICENSE.txt
14
13
  Classifier: Development Status :: 5 - Production/Stable
15
14
  Classifier: Framework :: Robot Framework
16
15
  Classifier: Framework :: Robot Framework :: Tool
@@ -26,7 +25,7 @@ Classifier: Topic :: Utilities
26
25
  Classifier: Typing :: Typed
27
26
  Requires-Python: >=3.8
28
27
  Requires-Dist: platformdirs<4.4.0,>=3.2.0
29
- Requires-Dist: robotcode-core==0.96.0
28
+ Requires-Dist: robotcode-core==0.97.0
30
29
  Requires-Dist: robotframework>=4.1.0
31
30
  Requires-Dist: tomli>=1.1.0; python_version < '3.11'
32
31
  Description-Content-Type: text/markdown
@@ -30,7 +30,7 @@ dependencies = [
30
30
  "robotframework>=4.1.0",
31
31
  "tomli>=1.1.0; python_version < '3.11'",
32
32
  "platformdirs>=3.2.0,<4.4.0",
33
- "robotcode-core==0.96.0",
33
+ "robotcode-core==0.97.0",
34
34
  ]
35
35
  dynamic = ["version"]
36
36
 
@@ -0,0 +1 @@
1
+ __version__ = "0.97.0"
@@ -55,14 +55,36 @@ class ConfigTypeError(TypeError):
55
55
  _ConfigType = TypeVar("_ConfigType", bound=BaseOptions)
56
56
 
57
57
 
58
+ class InvalidTomlError(ValueError):
59
+ pass
60
+
61
+
62
+ class InvalidTomlFileError(ValueError):
63
+ pass
64
+
65
+
66
+ def _load_toml(data: Union[str, Path]) -> Dict[str, Any]:
67
+ file = None
68
+ if isinstance(data, Path):
69
+ file = data
70
+ data = data.read_text("utf-8")
71
+
72
+ try:
73
+ return tomllib.loads(data)
74
+ except tomllib.TOMLDecodeError as e:
75
+ if file:
76
+ raise InvalidTomlFileError(f"Invalid TOML file'{file.absolute()}': {e}") from e
77
+ raise InvalidTomlError(f"Invalid TOML: {e}") from e
78
+
79
+
58
80
  def load_robot_config_from_robot_toml_str(__s: str) -> RobotConfig:
59
81
  return load_config_from_robot_toml_str(RobotConfig, __s)
60
82
 
61
83
 
62
84
  def load_config_from_robot_toml_str(
63
- config_type: Type[_ConfigType], data: Union[str, Dict[str, Any]], tool_name: Optional[str] = None
85
+ config_type: Type[_ConfigType], data: Union[str, Dict[str, Any], Path], tool_name: Optional[str] = None
64
86
  ) -> _ConfigType:
65
- dict_data = tomllib.loads(data) if isinstance(data, str) else data
87
+ dict_data = _load_toml(data) if isinstance(data, (str, Path)) else data
66
88
 
67
89
  if tool_name:
68
90
  try:
@@ -76,9 +98,9 @@ def load_config_from_robot_toml_str(
76
98
 
77
99
 
78
100
  def load_config_from_pyproject_toml_str(
79
- config_type: Type[_ConfigType], tool_name: str, data: Union[str, Dict[str, Any]]
101
+ config_type: Type[_ConfigType], tool_name: str, data: Union[str, Dict[str, Any], Path]
80
102
  ) -> _ConfigType:
81
- dict_data = tomllib.loads(data) if isinstance(data, str) else data
103
+ dict_data = _load_toml(data) if isinstance(data, (str, Path)) else data
82
104
 
83
105
  return from_dict(dict_data.get("tool", {}).get(tool_name, {}), config_type)
84
106
 
@@ -93,13 +115,13 @@ def _load_config_data_from_path(
93
115
  try:
94
116
  if path.name == PYPROJECT_TOML:
95
117
  return load_config_from_pyproject_toml_str(
96
- config_type, pyproject_toml_tool_name, path.read_text("utf-8") if data is None else data
118
+ config_type, pyproject_toml_tool_name, path if data is None else data
97
119
  )
98
120
 
99
121
  if path.name == ROBOT_TOML or path.name == LOCAL_ROBOT_TOML or path.suffix == ".toml":
100
122
  return load_config_from_robot_toml_str(
101
123
  config_type,
102
- path.read_text("utf-8") if data is None else data,
124
+ path if data is None else data,
103
125
  tool_name=robot_toml_tool_name,
104
126
  )
105
127
  raise TypeError("Unknown config file type.")
@@ -143,7 +165,7 @@ def load_config_from_path(
143
165
  verbose_callback(f"Load configuration from {__path if isinstance(__path, Path) else __path[0]}")
144
166
 
145
167
  p = __path if isinstance(__path, Path) else __path[0]
146
- data = tomllib.loads(p.read_text("utf-8"))
168
+ data = _load_toml(p)
147
169
 
148
170
  result.add_options(
149
171
  _load_config_data_from_path(
@@ -25,6 +25,7 @@ from typing import (
25
25
  final,
26
26
  )
27
27
 
28
+ from robot.errors import RobotError
28
29
  from robot.libraries import STDLIBS
29
30
  from robot.utils.text import split_args_from_name_or_path
30
31
  from robotcode.core.concurrent import RLock, run_as_task
@@ -32,7 +33,16 @@ from robotcode.core.documents_manager import DocumentsManager
32
33
  from robotcode.core.event import event
33
34
  from robotcode.core.filewatcher import FileWatcherEntry, FileWatcherManagerBase, FileWatcherManagerDummy
34
35
  from robotcode.core.language import language_id
35
- from robotcode.core.lsp.types import DocumentUri, FileChangeType, FileEvent
36
+ from robotcode.core.lsp.types import (
37
+ Diagnostic,
38
+ DiagnosticRelatedInformation,
39
+ DiagnosticSeverity,
40
+ DocumentUri,
41
+ FileChangeType,
42
+ FileEvent,
43
+ Location,
44
+ Range,
45
+ )
36
46
  from robotcode.core.text_document import TextDocument
37
47
  from robotcode.core.uri import Uri
38
48
  from robotcode.core.utils.caching import SimpleLRUCache
@@ -577,6 +587,8 @@ class ImportsManager:
577
587
  weakref.WeakKeyDictionary()
578
588
  )
579
589
 
590
+ self._diagnostics: List[Diagnostic] = []
591
+
580
592
  def __del__(self) -> None:
581
593
  try:
582
594
  if self._executor is not None:
@@ -584,6 +596,12 @@ class ImportsManager:
584
596
  except RuntimeError:
585
597
  pass
586
598
 
599
+ @property
600
+ def diagnostics(self) -> List[Diagnostic]:
601
+ self.get_command_line_variables()
602
+
603
+ return self._diagnostics
604
+
587
605
  @property
588
606
  def environment(self) -> Mapping[str, str]:
589
607
  return self._environment
@@ -647,18 +665,54 @@ class ImportsManager:
647
665
  ]
648
666
 
649
667
  if lib_doc.errors:
650
- # TODO add diagnostics
651
668
  for error in lib_doc.errors:
652
- self._logger.error(
653
- lambda: f"{error.type_name}: {error.message} in {error.source}:{error.line_no}"
669
+ self._diagnostics.append(
670
+ Diagnostic(
671
+ Range.zero(),
672
+ f"Processing variable file variable file '{name}({', '.join(args)})' failed"
673
+ + ("" if error.source is not None else f": {error.message}"),
674
+ DiagnosticSeverity.ERROR,
675
+ error.type_name,
676
+ related_information=(
677
+ [
678
+ DiagnosticRelatedInformation(
679
+ Location(
680
+ str(Uri.from_path(os.path.abspath(error.source))),
681
+ Range.from_int_range(
682
+ (error.line_no - 1) if error.line_no is not None else -1
683
+ ),
684
+ ),
685
+ error.message,
686
+ )
687
+ ]
688
+ if error.source is not None
689
+ else None
690
+ ),
691
+ )
654
692
  )
693
+ except RobotError as e:
694
+ self._diagnostics.append(
695
+ Diagnostic(
696
+ Range.zero(),
697
+ f"Error in command line variable file '{name}({', '.join(args)})': {e}",
698
+ DiagnosticSeverity.ERROR,
699
+ type(e).__name__,
700
+ )
701
+ )
655
702
  except (SystemExit, KeyboardInterrupt):
656
703
  raise
657
704
  except BaseException as e:
658
- # TODO add diagnostics
705
+ self._diagnostics.append(
706
+ Diagnostic(
707
+ Range.zero(),
708
+ f"Error in command line variable file '{name}({', '.join(args)})': {e}",
709
+ DiagnosticSeverity.ERROR,
710
+ type(e).__name__,
711
+ )
712
+ )
659
713
  ex = e
660
714
  self._logger.exception(
661
- lambda: f"Error getting command line variables: {ex}",
715
+ lambda: f"Error in command line variable file '{name}({', '.join(args)})'",
662
716
  exc_info=ex,
663
717
  )
664
718
 
@@ -75,6 +75,7 @@ class WorkspaceConfig(ConfigBase):
75
75
 
76
76
  @dataclass
77
77
  class WorkspaceAnalysisConfig:
78
+ exclude_patterns: List[str] = field(default_factory=list)
78
79
  cache: CacheConfig = field(default_factory=CacheConfig)
79
80
  robot: AnalysisRobotConfig = field(default_factory=AnalysisRobotConfig)
80
81
  modifiers: AnalysisDiagnosticModifiersConfig = field(default_factory=AnalysisDiagnosticModifiersConfig)
@@ -1 +0,0 @@
1
- __version__ = "0.96.0"