robotcode-core 1.3.0.dev6__tar.gz → 1.5.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.
Files changed (35) hide show
  1. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/PKG-INFO +1 -1
  2. robotcode_core-1.5.0/src/robotcode/core/__version__.py +1 -0
  3. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/event.py +6 -6
  4. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/text_document.py +65 -1
  5. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/dataclasses.py +2 -2
  6. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/inspect.py +1 -1
  7. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/logging.py +9 -9
  8. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/workspace.py +1 -1
  9. robotcode_core-1.3.0.dev6/src/robotcode/core/__version__.py +0 -1
  10. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/.gitignore +0 -0
  11. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/LICENSE.txt +0 -0
  12. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/README.md +0 -0
  13. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/pyproject.toml +0 -0
  14. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/__init__.py +0 -0
  15. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/async_tools.py +0 -0
  16. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/concurrent.py +0 -0
  17. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/documents_manager.py +0 -0
  18. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/filewatcher.py +0 -0
  19. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/ignore_spec.py +0 -0
  20. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/language.py +0 -0
  21. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/lsp/__init__.py +0 -0
  22. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/lsp/types.py +0 -0
  23. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/py.typed +0 -0
  24. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/types.py +0 -0
  25. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/uri.py +0 -0
  26. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/__init__.py +0 -0
  27. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/caching.py +0 -0
  28. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/cli.py +0 -0
  29. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/debugpy.py +0 -0
  30. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/glob_path.py +0 -0
  31. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/net.py +0 -0
  32. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/path.py +0 -0
  33. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/process.py +0 -0
  34. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/safe_eval.py +0 -0
  35. {robotcode_core-1.3.0.dev6 → robotcode_core-1.5.0}/src/robotcode/core/utils/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotcode-core
3
- Version: 1.3.0.dev6
3
+ Version: 1.5.0
4
4
  Summary: Some core classes for RobotCode
5
5
  Project-URL: Homepage, https://robotcode.io
6
6
  Project-URL: Donate, https://opencollective.com/robotcode
@@ -0,0 +1 @@
1
+ __version__ = "1.5.0"
@@ -72,10 +72,10 @@ class EventResultIteratorBase(Generic[_TParams, _TResult]):
72
72
 
73
73
  def _notify(
74
74
  self,
75
- *__args: _TParams.args,
75
+ *__args: Any,
76
76
  return_exceptions: Optional[bool] = True,
77
77
  callback_filter: Optional[Callable[[Callable[..., Any]], bool]] = None,
78
- **__kwargs: _TParams.kwargs,
78
+ **__kwargs: Any,
79
79
  ) -> Iterator[Union[_TResult, BaseException]]:
80
80
  for method in filter(
81
81
  lambda x: callback_filter(x) if callback_filter is not None else True,
@@ -95,9 +95,9 @@ class EventResultIteratorBase(Generic[_TParams, _TResult]):
95
95
  class EventIterator(EventResultIteratorBase[_TParams, _TResult]):
96
96
  def __call__(
97
97
  self,
98
- *__args: _TParams.args,
98
+ *__args: Any,
99
99
  callback_filter: Optional[Callable[[Callable[..., Any]], bool]] = None,
100
- **__kwargs: _TParams.kwargs,
100
+ **__kwargs: Any,
101
101
  ) -> Iterator[Union[_TResult, BaseException]]:
102
102
  return self._notify(*__args, callback_filter=callback_filter, **__kwargs)
103
103
 
@@ -105,9 +105,9 @@ class EventIterator(EventResultIteratorBase[_TParams, _TResult]):
105
105
  class Event(EventResultIteratorBase[_TParams, _TResult]):
106
106
  def __call__(
107
107
  self,
108
- *__args: _TParams.args,
108
+ *__args: Any,
109
109
  callback_filter: Optional[Callable[[Callable[..., Any]], bool]] = None,
110
- **__kwargs: _TParams.kwargs,
110
+ **__kwargs: Any,
111
111
  ) -> List[Union[_TResult, BaseException]]:
112
112
  return list(self._notify(*__args, callback_filter=callback_filter, **__kwargs))
113
113
 
@@ -216,6 +216,70 @@ class TextDocument:
216
216
 
217
217
  return self._lines
218
218
 
219
+ def get_text(self, r: Range) -> str:
220
+ lines = self.get_lines()
221
+
222
+ start_pos = r.start
223
+ end_pos = r.end
224
+
225
+ # Validate range
226
+ if start_pos.line < 0 or start_pos.character < 0:
227
+ raise InvalidRangeError(f"Invalid start position: {start_pos}")
228
+ if end_pos.line < 0 or end_pos.character < 0:
229
+ raise InvalidRangeError(f"Invalid end position: {end_pos}")
230
+ if start_pos > end_pos:
231
+ raise InvalidRangeError(f"Start position is greater than end position: {r}")
232
+
233
+ # Handle case where range is beyond document
234
+ if start_pos.line >= len(lines):
235
+ return ""
236
+
237
+ # Single line case
238
+ if start_pos.line == end_pos.line:
239
+ if start_pos.line < len(lines):
240
+ line = lines[start_pos.line]
241
+ # Handle newline character at end of line
242
+ if line.endswith(("\n", "\r\n")):
243
+ line_content = line.rstrip("\r\n")
244
+ if end_pos.character > len(line_content):
245
+ # Include the newline character(s)
246
+ return line[start_pos.character :]
247
+
248
+ return line_content[start_pos.character : end_pos.character]
249
+
250
+ return line[start_pos.character : end_pos.character]
251
+ return ""
252
+
253
+ # Multi-line case
254
+ result_lines = []
255
+
256
+ # First line
257
+ if start_pos.line < len(lines):
258
+ first_line = lines[start_pos.line]
259
+ if first_line.endswith(("\n", "\r\n")):
260
+ result_lines.append(first_line[start_pos.character :])
261
+ else:
262
+ result_lines.append(first_line[start_pos.character :] + "\n")
263
+
264
+ # Middle lines
265
+ for line_idx in range(start_pos.line + 1, min(end_pos.line, len(lines))):
266
+ result_lines.append(lines[line_idx])
267
+
268
+ # Last line
269
+ if end_pos.line < len(lines):
270
+ last_line = lines[end_pos.line]
271
+ if last_line.endswith(("\n", "\r\n")):
272
+ line_content = last_line.rstrip("\r\n")
273
+ if end_pos.character > len(line_content):
274
+ # Include the newline character(s)
275
+ result_lines.append(last_line)
276
+ else:
277
+ result_lines.append(line_content[: end_pos.character])
278
+ else:
279
+ result_lines.append(last_line[: end_pos.character])
280
+
281
+ return "".join(result_lines)
282
+
219
283
  @event
220
284
  def cache_invalidate(sender) -> None: ...
221
285
 
@@ -226,7 +290,7 @@ class TextDocument:
226
290
  def _cache_invalidating(self) -> Iterator[None]:
227
291
  send_events = len(self._cache) > 0
228
292
  if send_events:
229
- self.cache_invalidate()
293
+ self.cache_invalidate(self)
230
294
  try:
231
295
  with self._lock:
232
296
  yield
@@ -647,7 +647,7 @@ def validate_types(expected_types: Union[type, Tuple[type, ...], None], value: A
647
647
  continue
648
648
 
649
649
  if (
650
- t is Any # type: ignore
650
+ t is Any
651
651
  or t is Ellipsis # type: ignore
652
652
  or isinstance(value, origin or t)
653
653
  or (
@@ -683,7 +683,7 @@ def validate_types(expected_types: Union[type, Tuple[type, ...], None], value: A
683
683
 
684
684
  return []
685
685
 
686
- if t is Any: # type: ignore
686
+ if t is Any:
687
687
  return []
688
688
 
689
689
  if isinstance(value, origin or t):
@@ -15,7 +15,7 @@ def iter_methods(
15
15
  m = v
16
16
  else:
17
17
  m = getattr(obj, name)
18
- if not inspect.ismethod(m): # type: ignore
18
+ if not inspect.ismethod(m):
19
19
  continue
20
20
 
21
21
  if predicate is None or predicate(m):
@@ -136,7 +136,7 @@ class LoggingDescriptor:
136
136
 
137
137
  if self.__func is not None:
138
138
  if isinstance(self.__func, staticmethod):
139
- returned_logger = self.__func.__func__() # type: ignore
139
+ returned_logger = self.__func.__func__()
140
140
  else:
141
141
  returned_logger = self.__func()
142
142
 
@@ -198,15 +198,14 @@ class LoggingDescriptor:
198
198
  extra: Optional[Mapping[str, object]] = None,
199
199
  **kwargs: Any,
200
200
  ) -> None:
201
- if (self.is_enabled_for(level) and condition is not None and condition()) or condition is None:
201
+ if self.is_enabled_for(level) and (condition is None or condition()):
202
202
  depth = 0
203
203
  if context_name is not None:
204
204
  depth = self._measure_contexts.get(context_name, 0)
205
205
 
206
- if depth > 0:
207
- extra = {**extra} if extra is not None else {}
208
- if "indent" not in extra:
209
- extra["indent"] = " " * depth
206
+ extra = {**extra} if extra is not None else {}
207
+ if "indent" not in extra:
208
+ extra["indent"] = (" " * depth) if depth > 0 else ""
210
209
 
211
210
  self.logger.log(
212
211
  level,
@@ -238,7 +237,6 @@ class LoggingDescriptor:
238
237
  **kwargs,
239
238
  )
240
239
 
241
- _log_measure_time = log
242
240
  _measure_contexts: Dict[str, int] = {}
243
241
 
244
242
  @contextmanager
@@ -259,11 +257,12 @@ class LoggingDescriptor:
259
257
 
260
258
  self._measure_contexts[context_name] = depth
261
259
 
262
- self._log_measure_time(
260
+ self.log(
263
261
  level,
264
262
  lambda: f"Start {msg() if callable(msg) else msg}",
265
263
  *args,
266
264
  context_name=context_name,
265
+ stacklevel=3,
267
266
  extra=extra,
268
267
  **kwargs,
269
268
  )
@@ -280,11 +279,12 @@ class LoggingDescriptor:
280
279
  if context_name is not None:
281
280
  self._measure_contexts[context_name] = depth
282
281
 
283
- self._log_measure_time(
282
+ self.log(
284
283
  level,
285
284
  lambda: f"End {msg() if callable(msg) else msg} took {duration:.4f} seconds",
286
285
  *args,
287
286
  context_name=context_name,
287
+ stacklevel=3,
288
288
  extra=extra,
289
289
  **kwargs,
290
290
  )
@@ -76,7 +76,7 @@ class Workspace:
76
76
  section: Type[TConfig],
77
77
  scope_uri: Union[str, Uri, None] = None,
78
78
  ) -> TConfig:
79
- result = self.settings
79
+ result: Any = self.settings
80
80
  for sub_key in str(section).split("."):
81
81
  if sub_key in result:
82
82
  result = result.get(sub_key, None)
@@ -1 +0,0 @@
1
- __version__ = "1.3.0-dev.6"