Skip to content

Commit 92c1911

Browse files
committed
refactor(core): move some files from core to utils
1 parent d67c57b commit 92c1911

File tree

81 files changed

+149
-107
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+149
-107
lines changed

docs/cli/reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
:prog_name: robotcode
55
:remove_ascii_art: true
66
:list_subcommands: true
7+
:style: table

hatch.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ extra-dependencies = [
139139
"mkdocs-glightbox",
140140

141141
# Extensions
142-
"mkdocs-click~=0.8.0",
142+
"mkdocs-click~=0.8.1",
143143
"pymdown-extensions~=9.6.0",
144144
# Necessary for syntax highlighting in code blocks
145145
"pygments",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from pathlib import Path
2+
3+
from robotcode.robot.config.model import RobotConfig
4+
5+
from .config import AnalyzerConfig
6+
7+
8+
class Analyzer:
9+
def __init__(self, config: AnalyzerConfig, robot_config: RobotConfig, root_folder: Path):
10+
self.config = config
11+
self.robot_config = robot_config
12+
self.root_folder = root_folder
13+
14+
# def run(self, *paths: Path) -> Iterator[Diagnostic]:
15+
# yield Diagnostic()
Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,52 @@
11
# ruff: noqa: RUF009
22
from dataclasses import dataclass
3-
from typing import List, Optional, Union
3+
from enum import Enum
4+
from typing import List, Optional
45

56
from robotcode.robot.config.model import BaseOptions, field
67

78

8-
@dataclass
9-
class Dummy:
10-
some_field: Optional[str] = field(default="some value", description="Some field")
9+
class CacheSaveLocation(Enum):
10+
WORKSPACE_FOLDER = "workspaceFolder"
11+
WORKSPACE_STORAGE = "workspaceStorage"
1112

1213

1314
@dataclass
1415
class AnalyzerConfig(BaseOptions):
15-
select: Optional[List[Union[str, Dummy]]] = field(description="Selects which rules are run.")
16-
extend_select: Optional[List[Union[str, Dummy]]] = field(description="Extends the rules which are run.")
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.")
1718
ignore: Optional[List[str]] = field(description="Defines which rules are ignored.")
1819
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+
)

packages/core/src/robotcode/core/async_tools.py

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from typing import (
1717
Any,
1818
AsyncIterator,
19-
Awaitable,
2019
Callable,
2120
Coroutine,
2221
Deque,
@@ -26,6 +25,7 @@
2625
MutableSet,
2726
Optional,
2827
Protocol,
28+
Set,
2929
Type,
3030
TypeVar,
3131
Union,
@@ -559,14 +559,19 @@ def release(self) -> None:
559559
self._task = None
560560

561561

562+
_global_futures_set: Set[asyncio.Future[Any]] = set()
563+
564+
562565
class FutureInfo:
563566
def __init__(self, future: asyncio.Future[Any]) -> None:
564567
self.task: weakref.ref[asyncio.Future[Any]] = weakref.ref(future)
565568
self.children: weakref.WeakSet[asyncio.Future[Any]] = weakref.WeakSet()
566-
569+
_global_futures_set.add(future)
567570
future.add_done_callback(self._done)
568571

569572
def _done(self, future: asyncio.Future[Any]) -> None:
573+
_global_futures_set.discard(future)
574+
570575
if future.cancelled():
571576
for t in self.children.copy():
572577
if not t.done() and not t.cancelled() and t.get_loop().is_running():
@@ -628,19 +633,6 @@ async def create_task(
628633
return result
629634

630635

631-
def create_delayed_sub_task(
632-
coro: Awaitable[_T], *, delay: float, name: Optional[str] = None, loop: Optional[asyncio.AbstractEventLoop] = None
633-
) -> asyncio.Task[Optional[_T]]:
634-
async def run() -> Optional[_T]:
635-
try:
636-
await asyncio.sleep(delay)
637-
return await coro
638-
except asyncio.CancelledError:
639-
return None
640-
641-
return create_sub_task(run(), name=name, loop=loop)
642-
643-
644636
def create_sub_future(loop: Optional[asyncio.AbstractEventLoop] = None) -> asyncio.Future[Any]:
645637
ct = get_current_future_info()
646638

packages/core/src/robotcode/core/lsp/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from dataclasses import dataclass
1414
from typing import Any, Dict, Iterator, List, Literal, Optional, Tuple, Union
1515

16-
from robotcode.core.dataclasses import CamelSnakeMixin
16+
from robotcode.core.utils.dataclasses import CamelSnakeMixin
1717

1818
__lsp_version__ = "3.17.0"
1919

packages/core/src/robotcode/core/utils/debugpy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Optional, Sequence, Tuple, Union
22

3-
from ..logging import LoggingDescriptor
3+
from .logging import LoggingDescriptor
44
from .net import find_free_port
55

66
_logger = LoggingDescriptor(name=__name__)

packages/debugger/src/robotcode/debugger/dap_types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from enum import Enum
55
from typing import Any, Dict, Iterator, List, Literal, Optional, Union
66

7-
from robotcode.core.dataclasses import to_camel_case, to_snake_case
7+
from robotcode.core.utils.dataclasses import to_camel_case, to_snake_case
88

99

1010
@dataclass

0 commit comments

Comments
 (0)