Skip to content

Commit 8a042c9

Browse files
committed
chore: some reformatting, corrections and fixing pyright hints
1 parent 4b04c7a commit 8a042c9

File tree

7 files changed

+69
-29
lines changed

7 files changed

+69
-29
lines changed

bundled_requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
typing-extensions>=4.4.0
12
click>=8.1.0
23
pluggy>=1.0.0
4+
tomli > 2.0.0

packages/core/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ classifiers = [
2323
"Topic :: Utilities",
2424
"Typing :: Typed",
2525
]
26-
dependencies = []
26+
dependencies = ["typing-extensions>=4.4.0"]
2727
dynamic = ["version"]
2828

2929
[project.urls]

packages/language_server/robotcode/language_server/robotframework/diagnostics/library_doc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,15 +1101,15 @@ def _std_capture() -> Iterator[io.StringIO]:
11011101
old_stdout = sys.stdout
11021102
old_stderr = sys.stderr
11031103

1104-
capturer = sys.stdout = sys.__stdout__ = sys.stderr = sys.__stderr__ = io.StringIO()
1104+
capturer = sys.stdout = sys.__stdout__ = sys.stderr = sys.__stderr__ = io.StringIO() # type: ignore
11051105

11061106
try:
11071107
yield capturer
11081108
finally:
11091109
sys.stderr = old_stderr
11101110
sys.stdout = old_stdout
1111-
sys.__stderr__ = old__stderr__
1112-
sys.__stdout__ = old__stdout__
1111+
sys.__stderr__ = old__stderr__ # type: ignore
1112+
sys.__stdout__ = old__stdout__ # type: ignore
11131113

11141114

11151115
class IgnoreEasterEggLibraryWarning(Exception): # noqa: N818

packages/language_server/robotcode/language_server/robotframework/parts/formatting.py

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,20 @@
88

99
from robotcode.core.logging import LoggingDescriptor
1010
from robotcode.language_server.common.decorators import language_id
11-
from robotcode.language_server.common.lsp_types import FormattingOptions, MessageType, Position, Range, TextEdit
11+
from robotcode.language_server.common.lsp_types import (
12+
FormattingOptions,
13+
MessageType,
14+
Position,
15+
Range,
16+
TextEdit,
17+
)
1218
from robotcode.language_server.common.text_document import TextDocument
1319
from robotcode.language_server.robotframework.utils.version import get_robot_version
1420

1521
if TYPE_CHECKING:
16-
from robotcode.language_server.robotframework.protocol import RobotLanguageServerProtocol
22+
from robotcode.language_server.robotframework.protocol import (
23+
RobotLanguageServerProtocol,
24+
)
1725

1826
from robotcode.core.utils.version import create_version_from_str
1927
from robotcode.language_server.robotframework.configuration import RoboTidyConfig
@@ -57,7 +65,11 @@ async def get_config(self, document: TextDocument) -> Optional[RoboTidyConfig]:
5765
@language_id("robotframework")
5866
@_logger.call
5967
async def format(
60-
self, sender: Any, document: TextDocument, options: FormattingOptions, **further_options: Any
68+
self,
69+
sender: Any,
70+
document: TextDocument,
71+
options: FormattingOptions,
72+
**further_options: Any,
6173
) -> Optional[List[TextEdit]]:
6274
config = await self.get_config(document)
6375

@@ -68,15 +80,20 @@ async def format(
6880
return await self.format_internal(document, options, **further_options)
6981

7082
self.parent.window.show_message(
71-
"RobotFramework formatter is not available, please install 'robotframework-tidy'.", MessageType.ERROR
83+
"RobotFramework formatter is not available, please install 'robotframework-tidy'.",
84+
MessageType.ERROR,
7285
)
7386

7487
return None
7588

7689
RE_LINEBREAKS = re.compile(r"\r\n|\r|\n")
7790

7891
async def format_robot_tidy(
79-
self, document: TextDocument, options: FormattingOptions, range: Optional[Range] = None, **further_options: Any
92+
self,
93+
document: TextDocument,
94+
options: FormattingOptions,
95+
range: Optional[Range] = None,
96+
**further_options: Any,
8097
) -> Optional[List[TextEdit]]:
8198
from difflib import SequenceMatcher
8299

@@ -98,7 +115,8 @@ async def format_robot_tidy(
98115
robot_tidy.config.formatting.end_line = range.end.line + 1
99116

100117
disabler_finder = RegisterDisablers(
101-
robot_tidy.config.formatting.start_line, robot_tidy.config.formatting.end_line
118+
robot_tidy.config.formatting.start_line,
119+
robot_tidy.config.formatting.end_line,
102120
)
103121
disabler_finder.visit(model)
104122
if disabler_finder.file_disabled:
@@ -118,7 +136,8 @@ async def format_robot_tidy(
118136
from robotidy.disablers import RegisterDisablers
119137

120138
disabler_finder = RegisterDisablers(
121-
robot_tidy.formatting_config.start_line, robot_tidy.formatting_config.end_line
139+
robot_tidy.formatting_config.start_line,
140+
robot_tidy.formatting_config.end_line,
122141
)
123142
disabler_finder.visit(model)
124143
if disabler_finder.file_disabled:
@@ -170,7 +189,7 @@ async def format_internal(
170189
self, document: TextDocument, options: FormattingOptions, **further_options: Any
171190
) -> Optional[List[TextEdit]]:
172191
from robot.parsing.model.blocks import File
173-
from robot.tidypkg import (
192+
from robot.tidypkg import ( # pyright: ignore [reportMissingImports]
174193
Aligner,
175194
Cleaner,
176195
NewlineNormalizer,
@@ -182,7 +201,11 @@ async def format_internal(
182201
Cleaner().visit(model)
183202
NewlineNormalizer(self.line_separator, self.short_test_name_length).visit(model)
184203
SeparatorNormalizer(self.use_pipes, self.space_count).visit(model)
185-
Aligner(self.short_test_name_length, self.setting_and_variable_name_length, self.use_pipes).visit(model)
204+
Aligner(
205+
self.short_test_name_length,
206+
self.setting_and_variable_name_length,
207+
self.use_pipes,
208+
).visit(model)
186209

187210
with io.StringIO() as s:
188211
model.save(s)
@@ -191,15 +214,23 @@ async def format_internal(
191214
TextEdit(
192215
range=Range(
193216
start=Position(line=0, character=0),
194-
end=Position(line=len(document.get_lines()), character=len((document.get_lines())[-1])),
217+
end=Position(
218+
line=len(document.get_lines()),
219+
character=len((document.get_lines())[-1]),
220+
),
195221
),
196222
new_text=s.getvalue(),
197223
)
198224
]
199225

200226
@language_id("robotframework")
201227
async def format_range(
202-
self, sender: Any, document: TextDocument, range: Range, options: FormattingOptions, **further_options: Any
228+
self,
229+
sender: Any,
230+
document: TextDocument,
231+
range: Range,
232+
options: FormattingOptions,
233+
**further_options: Any,
203234
) -> Optional[List[TextEdit]]:
204235
config = await self.get_config(document)
205236
if config and config.enabled and robotidy_installed():
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.27.1"
1+
__version__ = "0.27.2"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.27.1"
1+
__version__ = "0.27.2"

pyproject.toml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ path = "robotcode/cli/__version__.py"
8282
only-include = ["robotcode", "CHANGELOG.md"]
8383

8484
[tool.hatch.build.targets.wheel]
85-
only-include = ["robotcode", "CHANGELOG.md"]
85+
only-include = ["robotcode"]
8686

8787

8888
[tool.hatch.envs.default]
@@ -152,6 +152,7 @@ matrix.rf.dependencies = [
152152

153153
[tool.hatch.envs.lint]
154154
skip-install = true
155+
extra-dependencies = ["tomli>=2.0.0"]
155156
features = ["yaml", "rest", "lint", "tidy"]
156157

157158
[tool.hatch.envs.lint.scripts]
@@ -182,6 +183,9 @@ version_variable = [
182183
"packages/jsonrpc2/robotcode/jsonrpc2/__version__.py:__version__",
183184
"packages/language_server/robotcode/language_server/__version__.py:__version__",
184185
"packages/modifiers/robotcode/modifiers/__version__.py:__version__",
186+
"packages/modifiers/robotcode/plugin/__version__.py:__version__",
187+
"packages/modifiers/robotcode/runner/__version__.py:__version__",
188+
185189
]
186190
version_pattern = ['package.json:"version": "{version}"']
187191
branch = "main"
@@ -322,25 +326,28 @@ module = [
322326
"robotidy.*",
323327
"robocop.*",
324328
"pytest_regtest.*",
325-
"pluggy"
329+
"pluggy",
326330
]
327331
ignore_missing_imports = true
328332

329333

330-
[tool.hatch.build.targets.wheel.hooks.mypyc]
331-
enable-by-default = false
332-
dependencies = ["hatch-mypyc", "types-PyYAML", "types-docutils"]
333-
require-runtime-dependencies = true
334-
include = [
335-
"robotcode/utils/glob_path.py",
336-
"robotcode/language_server/robotframework/diagnostics/analyzer.py",
337-
]
338-
exclude = ["__main__.py", "__version__.py", "__init__.py", "typings", "tests"]
334+
# [tool.hatch.build.targets.wheel.hooks.mypyc]
335+
# enable-by-default = false
336+
# dependencies = ["hatch-mypyc", "types-PyYAML", "types-docutils"]
337+
# require-runtime-dependencies = true
338+
# include = [
339+
# "robotcode/utils/glob_path.py",
340+
# "robotcode/language_server/robotframework/diagnostics/analyzer.py",
341+
# ]
342+
# exclude = ["__main__.py", "__version__.py", "__init__.py", "typings", "tests"]
339343

340344

341-
[tool.hatch.build.targets.wheel.hooks.mypyc.options]
345+
# [tool.hatch.build.targets.wheel.hooks.mypyc.options]
342346
# # opt_level = "3"
343347
# multi_file = true
344348
#separate = true
345349
#verbose = true
346350
#include_runtime_files = false
351+
352+
[tool.pyright]
353+
exclude = ["**/.hatch", "**/node_modules", "**/__pycache__", "bundled/libs"]

0 commit comments

Comments
 (0)