Skip to content

Commit a3b6fd7

Browse files
committed
codeannotations
1 parent 1944b1b commit a3b6fd7

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

code_annotations/annotation_errors.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
List possible annotation error types.
33
"""
4-
import typing as t
54
from collections import namedtuple
65

76
AnnotationError = namedtuple(
@@ -12,8 +11,6 @@
1211
# to expose errors to pylint.
1312
TYPES: list[AnnotationError] = []
1413

15-
T = t.TypeVar('T', bound=AnnotationError)
16-
1714

1815
def add_error_type(message: str, symbol: str, description: str) -> AnnotationError:
1916
"""

code_annotations/find_django.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import inspect
66
import os
7+
import re
78
import sys
89
import typing as t
910

@@ -28,8 +29,8 @@ def __init__(self, config: AnnotationConfig, app_name: str | None = None) -> Non
2829
Initialize for DjangoSearch.
2930
"""
3031
super().__init__(config)
31-
self.local_models: t.Set[t.Type[models.Model]]
32-
self.non_local_models: t.Set[t.Type[models.Model]]
32+
self.local_models: set[t.Type[models.Model]]
33+
self.non_local_models: set[t.Type[models.Model]]
3334
self.local_models, self.non_local_models, total, annotation_eligible = (
3435
self.get_models_requiring_annotations(app_name)
3536
)
@@ -127,7 +128,7 @@ def _append_model_annotations(
127128
self,
128129
model_type: t.Type[models.Model],
129130
model_id: str,
130-
query: t.Pattern[str],
131+
query: re.Pattern[str],
131132
model_annotations: list[dict[str, t.Any]]
132133
) -> None:
133134
"""
@@ -448,8 +449,8 @@ def setup_django() -> None:
448449
def get_models_requiring_annotations(
449450
app_name: str | None = None
450451
) -> tuple[
451-
t.Set[t.Type[models.Model]],
452-
t.Set[t.Type[models.Model]],
452+
set[t.Type[models.Model]],
453+
set[t.Type[models.Model]],
453454
int,
454455
list[str]
455456
]:
@@ -468,8 +469,8 @@ def get_models_requiring_annotations(
468469
Tuple of local models, non-local models, total model count, and annotation eligible model IDs
469470
"""
470471
DjangoSearch.setup_django()
471-
local_models: t.Set[t.Type[models.Model]] = set()
472-
non_local_models: t.Set[t.Type[models.Model]] = set()
472+
local_models: set[t.Type[models.Model]] = set()
473+
non_local_models: set[t.Type[models.Model]] = set()
473474
annotation_eligible_models: list[str] = []
474475
total_models = 0
475476

code_annotations/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def clean_abs_path(filename_to_clean: str, parent_path: str) -> str:
121121
return os.path.relpath(filename_to_clean, parent_path)
122122

123123

124-
def get_annotation_regex(annotation_regexes: list[str]) -> t.Pattern[str]:
124+
def get_annotation_regex(annotation_regexes: list[str]) -> re.Pattern[str]:
125125
"""
126126
Return the full regex to search inside comments for configured annotations.
127127

0 commit comments

Comments
 (0)