Skip to content

Commit 3ed79d9

Browse files
committed
Handle DEDENT token, warn on start failure, pre-commit hook updates and fixes
1 parent 124f61e commit 3ed79d9

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ repos:
2020
- id: sort-simple-yaml
2121
files: .pre-commit-config.yaml
2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.12.11
23+
rev: v0.13.1
2424
hooks:
2525
- id: ruff-format
2626
- id: ruff-check
@@ -38,10 +38,10 @@ repos:
3838
additional_dependencies:
3939
- tomli
4040
- repo: https://github.com/adhtruong/mirrors-typos
41-
rev: v1.35.6
41+
rev: v1.36.2
4242
hooks:
4343
- id: typos
4444
- repo: https://github.com/woodruffw/zizmor-pre-commit
45-
rev: v1.12.1
45+
rev: v1.13.0
4646
hooks:
4747
- id: zizmor

src/idlemypyextension/annotate.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,10 @@ def read_line() -> str:
480480
tokens.append(ArgumentDefault(previous + string))
481481
else:
482482
tokens.append(ArgumentDefault(string))
483-
elif tok_name[token.type] == "INDENT": # pragma: nocover
483+
elif (
484+
tok_name[token.type] == "INDENT"
485+
or tok_name[token.type] == "DEDENT"
486+
): # pragma: nocover
484487
tokens.append(EndSeparator(string))
485488
elif tok_name[token.type] == "FSTRING_START":
486489
tokens.append(

src/idlemypyextension/extension.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def debug(message: object) -> None:
6363
##as_str = as_str.replace(home_directory, "~")
6464
##as_str = as_str.replace(username, "<username>")
6565

66-
print(f"\n[{__title__}] DEBUG: {as_str}")
66+
print(f"\n[{__name__}] DEBUG: {as_str}")
6767

6868

6969
MYPY_ERROR_TYPE: Final = re.compile(r" \[([a-z\-]+)\]\s*$")
@@ -531,12 +531,16 @@ async def ensure_daemon_running(self) -> bool:
531531
if x
532532
)
533533
debug(f"{command = }")
534-
return await client.start(
535-
self.status_file,
536-
flags=self.flags,
537-
daemon_timeout=self.daemon_timeout,
538-
log_file=self.log_file,
539-
)
534+
try:
535+
return await client.start(
536+
self.status_file,
537+
flags=self.flags,
538+
daemon_timeout=self.daemon_timeout,
539+
log_file=self.log_file,
540+
)
541+
except (Exception, SystemExit) as exc:
542+
utils.extension_log_exception(exc)
543+
return False
540544

541545
async def shutdown_dmypy_daemon_event_async(
542546
self,
@@ -932,7 +936,7 @@ async def dmypy_goto_definition_event_async(
932936

933937
response_tuple = maybe_response
934938
assert isinstance(response_tuple, tuple)
935-
raw_locations, file, start_line = response_tuple
939+
raw_locations, _file, _start_line = response_tuple
936940

937941
# Just read first one
938942
raw_location = raw_locations.splitlines()[0]

src/idlemypyextension/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ def remove_selected_extension_comments(self) -> bool:
888888
Changes are wrapped in an undo block.
889889
"""
890890
# Get selected region lines
891-
head, _tail, chars, lines = self.formatter.get_region()
891+
head, _tail, _chars, lines = self.formatter.get_region()
892892
region_start, _col = get_line_col(head)
893893

894894
edited = False

tests/test_annotate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def test_tokenize(text: str, tokens: list[annotate.Token]) -> None:
196196
def test_invalid_tokenize() -> None:
197197
with pytest.raises(
198198
annotate.ParseError,
199-
match="Could not parse '\\$HOME' from 'path.\\$HOME'",
199+
match="Could not parse '\\$HOME' from 'path\\.\\$HOME'",
200200
):
201201
annotate.tokenize("path.$HOME")
202202

0 commit comments

Comments
 (0)