Skip to content

Commit 615a6a2

Browse files
committed
pyupgrade to 3.14
1 parent a79c517 commit 615a6a2

45 files changed

Lines changed: 101 additions & 101 deletions

File tree

Some content is hidden

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

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
line-length = 120
2-
target-version = "py313"
2+
target-version = "py314"
33

44
[format]
55
quote-style = "single"

src/notebook/bibtex/entry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class BibEntry:
128128
urldate: Annotated[BibString | None, BibFieldAnnotation()] = None
129129

130130
# Based on https://stackoverflow.com/a/77690186/2756776
131-
def __or__(self, other: 'BibEntry') -> 'BibEntry':
131+
def __or__(self, other: BibEntry) -> BibEntry:
132132
return BibEntry(**asdict(self) | asdict(other))
133133

134134
def _string_properties(self) -> Iterable[tuple[str, BibString]]:

src/notebook/bibtex/parsing/parser.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def skip_whitespace_and_comments(self) -> BibToken | None:
4141

4242
return None
4343

44-
def parse_entry_name(self, name_context: 'BibValueContext', existing_names: Collection[str]) -> str:
44+
def parse_entry_name(self, name_context: BibValueContext, existing_names: Collection[str]) -> str:
4545
# Entry names may even contain %, which is otherwise used for comments
4646
while (head := self.peek()) and head.kind not in ['CLOSING_BRACE', 'COMMA', 'LINE_BREAK']:
4747
self.advance()
@@ -60,7 +60,7 @@ def parse_entry_name(self, name_context: 'BibValueContext', existing_names: Coll
6060

6161
return entry_name
6262

63-
def parse_property_key(self, entry_context: 'BibEntryContext', existing_keys: Collection[str]) -> str:
63+
def parse_property_key(self, entry_context: BibEntryContext, existing_keys: Collection[str]) -> str:
6464
head = self.peek_unsafe()
6565

6666
if head.kind != 'WORD':
@@ -75,7 +75,7 @@ def parse_property_key(self, entry_context: 'BibEntryContext', existing_keys: Co
7575
self.advance()
7676
return head.value
7777

78-
def _parse_escape_sequence(self, value_context: 'BibValueContext') -> str:
78+
def _parse_escape_sequence(self, value_context: BibValueContext) -> str:
7979
lookahead = self.peek_multiple(2)
8080

8181
if len(lookahead) == 1:
@@ -90,7 +90,7 @@ def _parse_escape_sequence(self, value_context: 'BibValueContext') -> str:
9090
case _:
9191
return '\\' + lookahead[1].value
9292

93-
def parse_value_in_context(self, value_context: 'BibValueContext', key: str, *, quotes: bool) -> None:
93+
def parse_value_in_context(self, value_context: BibValueContext, key: str, *, quotes: bool) -> None:
9494
self.advance()
9595

9696
builder = value_context.string_builder
@@ -190,7 +190,7 @@ def parse_raw_value(self) -> BibString:
190190
def parse_author_string(self, source: BibString) -> BibAuthor:
191191
return BibAuthor(full_name=source.strip())
192192

193-
def parse_list(self, value_context: 'BibValueContext') -> Iterable[BibString]:
193+
def parse_list(self, value_context: BibValueContext) -> Iterable[BibString]:
194194
value = value_context.string_builder.get_value()
195195
expecting_and = False
196196
buffer = list[BibString]()
@@ -216,11 +216,11 @@ def parse_list(self, value_context: 'BibValueContext') -> Iterable[BibString]:
216216
if len(buffer) > 0:
217217
yield CompositeString(buffer) if len(buffer) > 1 else buffer[0].strip()
218218

219-
def parse_authors(self, value_context: 'BibValueContext') -> Iterable[BibAuthor]:
219+
def parse_authors(self, value_context: BibValueContext) -> Iterable[BibAuthor]:
220220
for entry in self.parse_list(value_context):
221221
yield self.parse_author_string(entry)
222222

223-
def perform_inline_validation(self, value_context: 'BibValueContext', key: str) -> None:
223+
def perform_inline_validation(self, value_context: BibValueContext, key: str) -> None:
224224
value_str = str(value_context.string_builder.get_value())
225225

226226
if len(value_str) == 0 or value_str.isspace():
@@ -230,7 +230,7 @@ def perform_inline_validation(self, value_context: 'BibValueContext', key: str)
230230
for _ in self.parse_authors(value_context):
231231
pass
232232

233-
def parse_entry_properties(self, entry_context: 'BibEntryContext') -> Iterable[tuple[str, 'BibValueContext']]:
233+
def parse_entry_properties(self, entry_context: BibEntryContext) -> Iterable[tuple[str, BibValueContext]]:
234234
existing_keys = set[str]()
235235
last_comma: BibToken | None = None
236236

@@ -293,12 +293,12 @@ def parse_entry_properties(self, entry_context: 'BibEntryContext') -> Iterable[t
293293
if last_comma is not None:
294294
raise entry_context.annotate_token_error('Trailing commas are disallowed', token=last_comma)
295295

296-
def perform_global_validation(self, entry_context: 'BibEntryContext', properties: dict[str, 'BibValueContext']) -> None:
296+
def perform_global_validation(self, entry_context: BibEntryContext, properties: dict[str, BibValueContext]) -> None:
297297
if 'title' not in properties:
298298
raise entry_context.annotate_context_error('Entry without title')
299299

300300
@list_accumulator
301-
def process_authors(self, properties: dict[str, 'BibValueContext'], key: str) -> Iterable[BibAuthor]:
301+
def process_authors(self, properties: dict[str, BibValueContext], key: str) -> Iterable[BibAuthor]:
302302
if key not in properties:
303303
return
304304

@@ -326,7 +326,7 @@ def process_authors(self, properties: dict[str, 'BibValueContext'], key: str) ->
326326
if short_value_context and len(short_segments) > 0:
327327
raise short_value_context.annotate_context_error(error_message)
328328

329-
def process_language(self, properties: dict[str, 'BibValueContext'], key: str) -> Sequence[BibString]:
329+
def process_language(self, properties: dict[str, BibValueContext], key: str) -> Sequence[BibString]:
330330
value_context = properties.pop(key, None)
331331

332332
if value_context is None:

src/notebook/bibtex/string.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def __eq__(self, other: object) -> bool:
2020

2121
return self.value == other.value
2222

23-
def strip(self) -> 'VerbatimString':
23+
def strip(self) -> VerbatimString:
2424
return self
2525

2626
lstrip = rstrip = strip
@@ -30,9 +30,9 @@ def isspace(self) -> bool:
3030

3131

3232
class CompositeString:
33-
segments: 'Sequence[BibString]'
33+
segments: Sequence[BibString]
3434

35-
def __init__(self, segments: 'Sequence[BibString]') -> None:
35+
def __init__(self, segments: Sequence[BibString]) -> None:
3636
self.segments = segments
3737

3838
def __str__(self) -> str:
@@ -47,7 +47,7 @@ def __eq__(self, other: object) -> bool:
4747

4848
return self.segments == other.segments
4949

50-
def strip(self) -> 'CompositeString':
50+
def strip(self) -> CompositeString:
5151
return self
5252

5353
lstrip = rstrip = strip

src/notebook/commands/common/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
class FormatterContext(NamedTuple):
1313
src: TextIO
1414
dest: TextIO
15-
logger: 'loguru.Logger'
15+
logger: loguru.Logger
1616

1717

1818
class FormatterContextManager:

src/notebook/commands/watcher/command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
WatchTarget = Literal['all', 'notebook', 'figures']
1919

2020

21-
async def iter_file_changes(logger: 'loguru.Logger') -> AsyncIterator:
21+
async def iter_file_changes(logger: loguru.Logger) -> AsyncIterator:
2222
with Inotify() as inotify:
2323
inotify.add_watch(ROOT_PATH, Mask.MODIFY)
2424
inotify.add_watch(ROOT_PATH / 'text', Mask.MODIFY)
@@ -36,7 +36,7 @@ async def iter_file_changes(logger: 'loguru.Logger') -> AsyncIterator:
3636
yield os.path.relpath(event.path, ROOT_PATH)
3737

3838

39-
async def setup_watchers(base_logger: 'loguru.Logger', *, no_aux: bool) -> None:
39+
async def setup_watchers(base_logger: loguru.Logger, *, no_aux: bool) -> None:
4040
runner = TaskRunner()
4141

4242
async for path in iter_file_changes(base_logger):

src/notebook/commands/watcher/task.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
class WatcherTask(abc.ABC):
12-
sublogger: 'loguru.Logger'
12+
sublogger: loguru.Logger
1313
out_buffer: int | None
1414

1515
def __eq__(self, other: object) -> bool:
@@ -23,11 +23,11 @@ def __hash__(self) -> int:
2323
def command(self) -> str:
2424
...
2525

26-
async def pre_process(self, runner: 'TaskRunner') -> None:
26+
async def pre_process(self, runner: TaskRunner) -> None:
2727
pass
2828

29-
async def post_process(self, runner: 'TaskRunner') -> None:
29+
async def post_process(self, runner: TaskRunner) -> None:
3030
pass
3131

32-
async def on_failure(self, runner: 'TaskRunner') -> None:
32+
async def on_failure(self, runner: TaskRunner) -> None:
3333
pass

src/notebook/commands/watcher/tasks/asymptote.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class AsymptoteTask(WatcherTask):
1313
src_path: pathlib.Path
1414
out_buffer: int | None = None
1515

16-
def __init__(self, base_logger: 'loguru.Logger', src_path: pathlib.Path | str) -> None:
16+
def __init__(self, base_logger: loguru.Logger, src_path: pathlib.Path | str) -> None:
1717
self.src_path = pathlib.Path(src_path)
1818
self.base_logger = base_logger
1919
self.sublogger = base_logger.bind(logger=str(self.src_path))

src/notebook/commands/watcher/tasks/biber.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212

1313

1414
class BiberTask(WatcherTask):
15-
base_logger: 'loguru.Logger'
15+
base_logger: loguru.Logger
1616
out_buffer: int | None = asyncio.subprocess.DEVNULL
1717
tex_path: pathlib.Path
1818

19-
def __init__(self, base_logger: 'loguru.Logger', tex_path: pathlib.Path | str) -> None:
19+
def __init__(self, base_logger: loguru.Logger, tex_path: pathlib.Path | str) -> None:
2020
self.tex_path = pathlib.Path(tex_path)
2121
self.base_logger = base_logger
2222
self.sublogger = base_logger.bind(logger=str(os.path.relpath(self.bcf_path, ROOT_PATH)))

src/notebook/commands/watcher/tasks/latex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class LaTeXTask(WatcherTask):
1919
tex_path: pathlib.Path
2020
out_buffer: int | None = asyncio.subprocess.DEVNULL
2121

22-
def __init__(self, base_logger: 'loguru.Logger', tex_path: pathlib.Path | str) -> None:
22+
def __init__(self, base_logger: loguru.Logger, tex_path: pathlib.Path | str) -> None:
2323
self.tex_path = pathlib.Path(tex_path)
2424
self.base_logger = base_logger
2525
self.sublogger = base_logger.bind(logger=str(os.path.relpath(self.tex_path, ROOT_PATH)))

0 commit comments

Comments
 (0)