Skip to content

Commit 21c3b2f

Browse files
committed
Clean lint errors.
1 parent 4952dc2 commit 21c3b2f

File tree

9 files changed

+22
-24
lines changed

9 files changed

+22
-24
lines changed

example/manage.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#!/usr/bin/env python
22
"""Django's command-line utility for administrative tasks."""
3+
34
import os
45
import sys
56

67

78
def main():
89
"""Run administrative tasks."""
910
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
11+
1012
try:
11-
from django.core.management import execute_from_command_line
13+
from django.core.management import execute_from_command_line # noqa: PLC0415
1214
except ImportError as exc:
1315
raise ImportError(
1416
"Couldn't import Django. Are you sure it's installed and "

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ dev-dependencies = [
6363
[tool.ruff]
6464
src = ["src"]
6565
exclude = []
66-
target-version = "py39"
66+
target-version = "py310"
6767
line-length = 120
6868
lint.select = [
6969
"A",
@@ -144,7 +144,7 @@ skip_empty = true
144144
sort = "cover"
145145

146146
[tool.mypy]
147-
python_version = "3.9"
147+
python_version = "3.10"
148148
warn_return_any = true
149149
warn_unused_configs = true
150150
ignore_missing_imports = true

src/dj_angles/attributes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Sequence
2-
from typing import Optional, SupportsIndex
2+
from typing import SupportsIndex
33

44
from dj_angles.exceptions import DuplicateAttributeError, MissingAttributeError
55
from dj_angles.tokenizer import yield_tokens
@@ -21,7 +21,7 @@ class Attribute:
2121
key: str
2222
"""Key of the attribute. Always defined."""
2323

24-
value: Optional[str] = None
24+
value: str | None = None
2525
"""Optional value of the attribute. Defaults to `None`."""
2626

2727
has_value: bool = False
@@ -88,7 +88,7 @@ def has(self, name: str) -> bool:
8888

8989
return self.get(name) is not None
9090

91-
def get(self, name: str) -> Optional[Attribute]:
91+
def get(self, name: str) -> Attribute | None:
9292
"""Get an :obj:`~dj_angles.attributes.Attribute` by name. Returns `None` if the attribute is missing.
9393
9494
Args:
@@ -123,7 +123,7 @@ def remove(self, key: str) -> None:
123123

124124
self._attributes = _attributes
125125

126-
def pluck_value(self, name: str) -> Optional[str]:
126+
def pluck_value(self, name: str) -> str | None:
127127
"""Get the value of an :obj:`~dj_angles.attributes.Attribute` by name and remove the attribute from the tag
128128
attributes.
129129

src/dj_angles/exceptions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import TYPE_CHECKING, Optional
1+
from typing import TYPE_CHECKING
22

33
if TYPE_CHECKING:
44
from dj_angles.tags import Tag
@@ -50,7 +50,7 @@ class InvalidAttributeError(Exception):
5050
name: str
5151
"""The name of the attribute."""
5252

53-
def __init__(self, name: str, message: Optional[str] = None):
53+
def __init__(self, name: str, message: str | None = None):
5454
super().__init__(message)
5555

5656
self.name = name

src/dj_angles/htmls.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import re
2-
from typing import Optional
32

43
from dj_angles.tags import Tag
54

@@ -24,7 +23,7 @@
2423
}
2524

2625

27-
def get_outer_html(html: str, start_idx: int) -> Optional[Tag]:
26+
def get_outer_html(html: str, start_idx: int) -> Tag | None:
2827
"""Get the outer HTML for just the tag at a given index.
2928
3029
Will not return HTML before the beginning of the tag or after the ending tag.
@@ -42,7 +41,7 @@ def get_outer_html(html: str, start_idx: int) -> Optional[Tag]:
4241
Tag: The tag at the given index. The outer HTML is set on `tag.outer_html`.
4342
"""
4443

45-
initial_tag: Optional[Tag] = None
44+
initial_tag: Tag | None = None
4645
idx = start_idx
4746
tag_html = ""
4847
tag_name = ""
@@ -108,8 +107,8 @@ def get_outer_html(html: str, start_idx: int) -> Optional[Tag]:
108107
def find_character(
109108
html: str,
110109
start_idx: int,
111-
character: Optional[str] = None,
112-
character_regex: Optional[str] = None,
110+
character: str | None = None,
111+
character_regex: str | None = None,
113112
*,
114113
reverse: bool = False,
115114
) -> int:

src/dj_angles/mappers/mapper.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from collections import UserDict
22
from collections.abc import Callable
3-
from typing import Optional, Union
3+
from typing import Optional
44

55
from django.utils.module_loading import import_string
66

@@ -10,7 +10,7 @@
1010
from dj_angles.modules import is_module_available
1111
from dj_angles.settings import get_setting
1212

13-
TAG_NAME_TO_DJANGO_TEMPLATE_TAG_MAP: dict[Optional[str], Union[Callable, str]] = {
13+
TAG_NAME_TO_DJANGO_TEMPLATE_TAG_MAP: dict[str | None, Callable | str] = {
1414
"extends": map_extends,
1515
"block": map_block,
1616
"verbatim": "verbatim",
@@ -43,7 +43,7 @@ class TagMap(UserDict):
4343
def __init__(self) -> None:
4444
super().__init__()
4545

46-
self.data: dict[Optional[str], Union[Callable, str]] = TAG_NAME_TO_DJANGO_TEMPLATE_TAG_MAP.copy()
46+
self.data: dict[str | None, Callable | str] = TAG_NAME_TO_DJANGO_TEMPLATE_TAG_MAP.copy()
4747

4848
# Add bird if installed
4949
self.add_module_mapper("django_bird", "bird", "dj_angles.mappers.map_bird")
@@ -86,7 +86,7 @@ def import_strings(self):
8686
except ImportError:
8787
pass
8888

89-
def add_module_mapper(self, module: str, tag_name: str, mapper: Union[str, Callable]) -> None:
89+
def add_module_mapper(self, module: str, tag_name: str, mapper: str | Callable) -> None:
9090
"""Add module mappers depending on whether the module is installed or not."""
9191

9292
if is_module_available(module):

src/dj_angles/templates.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
from typing import Optional
2-
31
from django.template import Template
42
from django.template.exceptions import TemplateDoesNotExist
53
from django.template.loader import select_template
64

75
from dj_angles.strings import dequotify
86

97

10-
def get_template(template_file: str) -> Optional[Template]:
8+
def get_template(template_file: str) -> Template | None:
119
"""Check for the template file by looking for different template file variations.
1210
1311
Currently, the only other variation is looking for the template file with an underscore

src/dj_angles/templatetags/dj_angles.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from datetime import date, datetime, time
2-
from typing import Union
32

43
from django import template
54

@@ -11,7 +10,7 @@
1110

1211

1312
@register.filter(name="dateformat")
14-
def dateformat(value: Union[datetime, date, time], date_format: str):
13+
def dateformat(value: datetime | date | time, date_format: str):
1514
return value.strftime(date_format)
1615

1716

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)