|
1 | 1 | import sys |
2 | 2 | from bisect import bisect_left |
3 | 3 | from typing import ( |
4 | | - Dict, |
5 | 4 | Generic, |
6 | | - List, |
7 | 5 | NamedTuple, |
8 | 6 | Optional, |
9 | | - Type, |
10 | 7 | TypeVar, |
11 | 8 | cast, |
12 | 9 | overload, |
|
17 | 14 | from qrcode.image.base import BaseImage |
18 | 15 | from qrcode.image.pure import PyPNGImage |
19 | 16 |
|
20 | | -ModulesType = List[List[Optional[bool]]] |
| 17 | +ModulesType = list[list[Optional[bool]]] |
21 | 18 | # Cache modules generated just based on the QR Code version |
22 | | -precomputed_qr_blanks: Dict[int, ModulesType] = {} |
| 19 | +precomputed_qr_blanks: dict[int, ModulesType] = {} |
23 | 20 |
|
24 | 21 |
|
25 | 22 | def make(data=None, **kwargs): |
@@ -84,7 +81,7 @@ def __init__( |
84 | 81 | error_correction=constants.ERROR_CORRECT_M, |
85 | 82 | box_size=10, |
86 | 83 | border=4, |
87 | | - image_factory: Optional[Type[GenericImage]] = None, |
| 84 | + image_factory: Optional[type[GenericImage]] = None, |
88 | 85 | mask_pattern=None, |
89 | 86 | ): |
90 | 87 | _check_box_size(box_size) |
@@ -336,7 +333,7 @@ def make_image( |
336 | 333 |
|
337 | 334 | @overload |
338 | 335 | def make_image( |
339 | | - self, image_factory: Type[GenericImageLocal] = None, **kwargs |
| 336 | + self, image_factory: type[GenericImageLocal] = None, **kwargs |
340 | 337 | ) -> GenericImageLocal: ... |
341 | 338 |
|
342 | 339 | def make_image(self, image_factory=None, **kwargs): |
@@ -527,13 +524,13 @@ def get_matrix(self): |
527 | 524 | code = [[False] * width] * self.border |
528 | 525 | x_border = [False] * self.border |
529 | 526 | for module in self.modules: |
530 | | - code.append(x_border + cast(List[bool], module) + x_border) |
| 527 | + code.append(x_border + cast(list[bool], module) + x_border) |
531 | 528 | code += [[False] * width] * self.border |
532 | 529 |
|
533 | 530 | return code |
534 | 531 |
|
535 | 532 | def active_with_neighbors(self, row: int, col: int) -> ActiveWithNeighbors: |
536 | | - context: List[bool] = [] |
| 533 | + context: list[bool] = [] |
537 | 534 | for r in range(row - 1, row + 2): |
538 | 535 | for c in range(col - 1, col + 2): |
539 | 536 | context.append(self.is_constrained(r, c) and bool(self.modules[r][c])) |
|
0 commit comments