robotcode-robot 0.108.0__py3-none-any.whl → 0.108.1__py3-none-any.whl

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 +1 @@
1
- __version__ = "0.108.0"
1
+ __version__ = "0.108.1"
@@ -5,6 +5,7 @@ from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
7
  Callable,
8
+ Generic,
8
9
  List,
9
10
  Optional,
10
11
  Tuple,
@@ -12,6 +13,8 @@ from typing import (
12
13
  cast,
13
14
  )
14
15
 
16
+ from typing_extensions import Concatenate, ParamSpec
17
+
15
18
  from robot.parsing.lexer.tokens import Token
16
19
  from robotcode.core.lsp.types import Position, Range
17
20
  from robotcode.robot.utils.match import normalize
@@ -41,6 +44,39 @@ def single_call(func: _F) -> _F:
41
44
  return cast(_F, wrapper)
42
45
 
43
46
 
47
+ P = ParamSpec("P")
48
+ R = TypeVar("R")
49
+
50
+
51
+ class cached_method(Generic[P, R]): # noqa: N801
52
+ def __init__(
53
+ self, func: Optional[Callable[Concatenate[Any, P], R]] = None, *, maxsize: Optional[int] = None
54
+ ) -> None:
55
+ self.func: Optional[Callable[Concatenate[Any, P], R]] = func
56
+ self._maxsize = maxsize
57
+ self.cache_name: Optional[str] = None
58
+ if func is not None:
59
+ functools.update_wrapper(self, func)
60
+
61
+ def __set_name__(self, owner: type, name: str) -> None:
62
+ self.cache_name = f"__cached_{owner.__name__}_{name}"
63
+
64
+ def __call__(self, func: Callable[Concatenate[Any, P], R]) -> "cached_method[P, R]":
65
+ self.func = func
66
+ functools.update_wrapper(self, func)
67
+ return self
68
+
69
+ def __get__(self, instance: Any, owner: Optional[type] = None) -> Callable[P, R]:
70
+ cached = instance.__dict__.get(self.cache_name, _NOT_SET)
71
+ if cached is _NOT_SET:
72
+ assert self.func is not None
73
+
74
+ bound_method = self.func.__get__(instance, owner)
75
+ cached = functools.lru_cache(maxsize=self._maxsize)(bound_method)
76
+ instance.__dict__[self.cache_name] = cached
77
+ return cast(Callable[P, R], cached)
78
+
79
+
44
80
  @dataclass
45
81
  class SourceEntity:
46
82
  line_no: int
@@ -80,6 +80,7 @@ from .entities import (
80
80
  LibraryArgumentDefinition,
81
81
  NativeValue,
82
82
  SourceEntity,
83
+ cached_method,
83
84
  single_call,
84
85
  )
85
86
 
@@ -362,7 +363,8 @@ class TypeDoc:
362
363
  )
363
364
  )
364
365
 
365
- def to_markdown(self, header_level: int = 2) -> str:
366
+ @cached_method
367
+ def to_markdown(self, header_level: int = 2, only_doc: bool = False) -> str:
366
368
  result = ""
367
369
 
368
370
  result += f"##{'#' * header_level} {self.name} ({self.type})\n\n"
@@ -378,19 +380,22 @@ class TypeDoc:
378
380
  else:
379
381
  result += self.doc
380
382
 
381
- if self.members:
382
- result += f"\n\n###{'#' * header_level} Allowed Values:\n\n"
383
- result += "- " + "\n- ".join(f"`{m.name}`" for m in self.members)
384
-
385
- if self.items:
386
- result += f"\n\n###{'#' * header_level} Dictionary Structure:\n\n"
387
- result += "```\n{"
388
- result += "\n ".join(f"'{m.key}': <{m.type}> {'# optional' if not m.required else ''}" for m in self.items)
389
- result += "\n}\n```"
383
+ if not only_doc:
384
+ if self.members:
385
+ result += f"\n\n###{'#' * header_level} Allowed Values:\n\n"
386
+ result += "- " + "\n- ".join(f"`{m.name}`" for m in self.members)
387
+
388
+ if self.items:
389
+ result += f"\n\n###{'#' * header_level} Dictionary Structure:\n\n"
390
+ result += "```\n{"
391
+ result += "\n ".join(
392
+ f"'{m.key}': <{m.type}> {'# optional' if not m.required else ''}" for m in self.items
393
+ )
394
+ result += "\n}\n```"
390
395
 
391
- if self.accepts:
392
- result += f"\n\n###{'#' * header_level} Converted Types:\n\n"
393
- result += "- " + "\n- ".join(self.accepts)
396
+ if self.accepts:
397
+ result += f"\n\n###{'#' * header_level} Converted Types:\n\n"
398
+ result += "- " + "\n- ".join(self.accepts)
394
399
 
395
400
  return result
396
401
 
@@ -475,6 +480,7 @@ class ArgumentInfo:
475
480
  def __str__(self) -> str:
476
481
  return self.signature()
477
482
 
483
+ @cached_method
478
484
  def signature(self, add_types: bool = True) -> str:
479
485
  prefix = ""
480
486
  if self.kind == KeywordArgumentKind.POSITIONAL_ONLY_MARKER:
@@ -721,6 +727,7 @@ class KeywordDoc(SourceEntity):
721
727
  ),
722
728
  )
723
729
 
730
+ @cached_method
724
731
  def to_markdown(
725
732
  self,
726
733
  add_signature: bool = True,
@@ -796,7 +803,7 @@ class KeywordDoc(SourceEntity):
796
803
 
797
804
  result += (
798
805
  f"\n| `{prefix}{a.name!s}`"
799
- f'| {": " if a.types else " "}'
806
+ f"| {': ' if a.types else ' '}"
800
807
  f"{escaped_pipe.join(f'`{escape_pipe(s)}`' for s in a.types) if a.types else ''} "
801
808
  f"| {'=' if a.default_value is not None else ''} "
802
809
  f"| {f'`{a.default_value!s}`' if a.default_value else ''} |"
@@ -832,6 +839,7 @@ class KeywordDoc(SourceEntity):
832
839
  + ")"
833
840
  )
834
841
 
842
+ @cached_method
835
843
  def parameter_signature(self, full_signatures: Optional[Sequence[int]] = None) -> str:
836
844
  return (
837
845
  "("
@@ -1094,6 +1102,7 @@ class LibraryDoc:
1094
1102
  ),
1095
1103
  )
1096
1104
 
1105
+ @cached_method
1097
1106
  def to_markdown(
1098
1107
  self,
1099
1108
  add_signature: bool = True,
@@ -1250,6 +1259,7 @@ class VariablesDoc(LibraryDoc):
1250
1259
 
1251
1260
  variables: List[ImportedVariableDefinition] = field(default_factory=list)
1252
1261
 
1262
+ @cached_method
1253
1263
  def to_markdown(
1254
1264
  self,
1255
1265
  add_signature: bool = True,
@@ -2081,6 +2091,7 @@ def get_library_doc(
2081
2091
  td.usages,
2082
2092
  [EnumMember(m.name, m.value) for m in td.members] if td.members else None,
2083
2093
  [TypedDictItem(i.key, i.type, i.required) for i in td.items] if td.items else None,
2094
+ # TODO nested types like Literals
2084
2095
  libname=libdoc.name,
2085
2096
  libtype=libdoc.type,
2086
2097
  doc_format=libdoc.doc_format,
@@ -2453,6 +2464,7 @@ class CompleteResultKind(Enum):
2453
2464
  VARIABLES_MODULE = "Variables Module"
2454
2465
  FOLDER = "Directory"
2455
2466
  KEYWORD = "Keyword"
2467
+ DOC_CACHE = "DOC_CACHE"
2456
2468
 
2457
2469
 
2458
2470
  class CompleteResult(NamedTuple):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotcode-robot
3
- Version: 0.108.0
3
+ Version: 0.108.1
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
@@ -26,7 +26,7 @@ Classifier: Topic :: Utilities
26
26
  Classifier: Typing :: Typed
27
27
  Requires-Python: >=3.8
28
28
  Requires-Dist: platformdirs<4.4.0,>=3.2.0
29
- Requires-Dist: robotcode-core==0.108.0
29
+ Requires-Dist: robotcode-core==0.108.1
30
30
  Requires-Dist: robotframework>=4.1.0
31
31
  Requires-Dist: tomli>=1.1.0; python_version < '3.11'
32
32
  Description-Content-Type: text/markdown
@@ -1,5 +1,5 @@
1
1
  robotcode/robot/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- robotcode/robot/__version__.py,sha256=JEOHZgUQDTlcB-baQWEy9fRq4GokkcN9OsdgKLdJmJM,24
2
+ robotcode/robot/__version__.py,sha256=IQQ_e541afAse9JmPaer7GeRfj6rNlMpvwjKwEOF2sg,24
3
3
  robotcode/robot/py.typed,sha256=bWew9mHgMy8LqMu7RuqQXFXLBxh2CRx0dUbSx-3wE48,27
4
4
  robotcode/robot/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  robotcode/robot/config/loader.py,sha256=qrP810HNMDpqhXopWa0dOa0Wq_zQfVctsNYKY6sLKGI,8654
@@ -9,11 +9,11 @@ robotcode/robot/diagnostics/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
9
9
  robotcode/robot/diagnostics/data_cache.py,sha256=Wge9HuxSUiBVMmrmlsYSMmG2ad7f3Texwox0Dm8lN7U,2969
10
10
  robotcode/robot/diagnostics/diagnostics_modifier.py,sha256=6zJdXBd6g1QM12XJbsHd8gNNysECMnWlne3q8XNgBDo,9797
11
11
  robotcode/robot/diagnostics/document_cache_helper.py,sha256=5H0S7qDCeoEmqjMLUE7EQy9iZcZTYIUl5H1Pdvn5s5I,23886
12
- robotcode/robot/diagnostics/entities.py,sha256=JCqwsjBZThpqiMxHzXKdnpV3z-5ndYOyF3buk4UKJrw,11695
12
+ robotcode/robot/diagnostics/entities.py,sha256=I55YMxXpl7C1Sx6GgxRqb7vWMK7uWIoB7GhR1X9b66c,12983
13
13
  robotcode/robot/diagnostics/errors.py,sha256=RGnE4KCgNxQ58hNMBuAD3Q-qWqZVWZSZsCnhBGtQScw,1975
14
14
  robotcode/robot/diagnostics/imports_manager.py,sha256=nrvK6W1KHYbfmHRyerHbY2s-9p9uVjRoJwa7PHc8rmg,61146
15
15
  robotcode/robot/diagnostics/keyword_finder.py,sha256=dm4BA0ccp5V4C65CkSYUJUNXegSmvG24uu09T3eL6a4,17319
16
- robotcode/robot/diagnostics/library_doc.py,sha256=e8qEay6B16ZMNGZgDxtq-dhmQILCtQiPEGkNuY-24X0,99987
16
+ robotcode/robot/diagnostics/library_doc.py,sha256=Mz4Y2w00qHTx42xZMznnMwOWn5SY2utJAciRLaqyY00,100341
17
17
  robotcode/robot/diagnostics/model_helper.py,sha256=nq78e6TQ9Anvz_VSLW560lRTKrRjBsh7NoWttEvJ2hw,30973
18
18
  robotcode/robot/diagnostics/namespace.py,sha256=oLBXJkj-JEX--OMh9hIDfzpZxKvDOwH6Sle-SZG9s-Y,78653
19
19
  robotcode/robot/diagnostics/namespace_analyzer.py,sha256=tZQOvPIsgrgLcynx_IRH4G7vXN0M_vZEtxBMC0ZMmO8,75653
@@ -26,7 +26,7 @@ robotcode/robot/utils/robot_path.py,sha256=Z-GVBOPA_xeD20bCJi4_AWaU0eQWvCym-YFty
26
26
  robotcode/robot/utils/stubs.py,sha256=umugZYAyneFNgqRJBRMJPzm0u0B_TH8Sx_y-ykXnxpw,351
27
27
  robotcode/robot/utils/variables.py,sha256=-ldL8mRRSYYW2pwlm8IpoDeQcG6LYBqaYyV_7U3xsIc,2174
28
28
  robotcode/robot/utils/visitor.py,sha256=nP3O0qh3YYuxR6S8wYJRBFfNwIVgsgohURBlrnFkRYQ,2299
29
- robotcode_robot-0.108.0.dist-info/METADATA,sha256=WtWBBM8Z1A7MbCtupTp6YJVC8PdnVCy1sfAZ-enm1Fs,2242
30
- robotcode_robot-0.108.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
- robotcode_robot-0.108.0.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
32
- robotcode_robot-0.108.0.dist-info/RECORD,,
29
+ robotcode_robot-0.108.1.dist-info/METADATA,sha256=XJHU5rIns0B26SyHM299Ygp00Tw6_xMwRzxj6IFJCsE,2242
30
+ robotcode_robot-0.108.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
31
+ robotcode_robot-0.108.1.dist-info/licenses/LICENSE.txt,sha256=B05uMshqTA74s-0ltyHKI6yoPfJ3zYgQbvcXfDVGFf8,10280
32
+ robotcode_robot-0.108.1.dist-info/RECORD,,