Skip to content

Commit 318bab4

Browse files
committed
Consistent Type annotation setup, overall typo fixes
1 parent 9c6d254 commit 318bab4

File tree

17 files changed

+56
-24
lines changed

17 files changed

+56
-24
lines changed

qrcode/LUT.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# Store all kinds of lookup table.
2-
3-
1+
"""
2+
Store all kinds of lookup table.
3+
"""
44
# # generate rsPoly lookup table.
55

66
# from qrcode import base
7-
7+
#
88
# def create_bytes(rs_blocks):
99
# for r in range(len(rs_blocks)):
1010
# dcCount = rs_blocks[r].data_count
@@ -13,7 +13,7 @@
1313
# for i in range(ecCount):
1414
# rsPoly = rsPoly * base.Polynomial([1, base.gexp(i)], 0)
1515
# return ecCount, rsPoly
16-
16+
#
1717
# rsPoly_LUT = {}
1818
# for version in range(1,41):
1919
# for error_correction in range(4):

qrcode/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from qrcode.main import QRCode
24
from qrcode.main import make # noqa
35
from qrcode.constants import ( # noqa

qrcode/base.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from typing import NamedTuple
24
from qrcode import constants
35

qrcode/console_scripts.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@
66
a pipe to a file an image is written. The default image format is PNG.
77
"""
88

9+
from __future__ import annotations
10+
911
import optparse
1012
import os
1113
import sys
12-
from typing import NoReturn, Optional
14+
from typing import NoReturn
1315
from collections.abc import Iterable
1416
from importlib import metadata
1517

@@ -122,7 +124,7 @@ def raise_error(msg: str) -> NoReturn:
122124
return
123125

124126
kwargs = {}
125-
aliases: Optional[DrawerAliases] = getattr(
127+
aliases: DrawerAliases | None = getattr(
126128
qr.image_factory, "drawer_aliases", None
127129
)
128130
if opts.factory_drawer:
@@ -156,7 +158,7 @@ def get_drawer_help() -> str:
156158
image = get_factory(module)
157159
except ImportError: # pragma: no cover
158160
continue
159-
aliases: Optional[DrawerAliases] = getattr(image, "drawer_aliases", None)
161+
aliases: DrawerAliases | None = getattr(image, "drawer_aliases", None)
160162
if not aliases:
161163
continue
162164
factories = help.setdefault(commas(aliases), set())

qrcode/constants.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import annotations
2+
13
# QR error correct levels
2-
ERROR_CORRECT_L = 1
3-
ERROR_CORRECT_M = 0
4-
ERROR_CORRECT_Q = 3
5-
ERROR_CORRECT_H = 2
4+
ERROR_CORRECT_L: int = 1
5+
ERROR_CORRECT_M: int = 0
6+
ERROR_CORRECT_Q: int = 3
7+
ERROR_CORRECT_H: int = 2

qrcode/exceptions.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
from __future__ import annotations
2+
3+
14
class DataOverflowError(Exception):
25
pass

qrcode/image/base.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
from __future__ import annotations
2+
13
import abc
2-
from typing import TYPE_CHECKING, Any, Optional, Union
4+
from typing import TYPE_CHECKING, Any, Union
35

46
from qrcode.image.styles.moduledrawers.base import QRModuleDrawer
57

@@ -15,8 +17,8 @@ class BaseImage:
1517
Base QRCode image output class.
1618
"""
1719

18-
kind: Optional[str] = None
19-
allowed_kinds: Optional[tuple[str]] = None
20+
kind: str | None = None
21+
allowed_kinds: tuple[str, ...] | None = None
2022
needs_context = False
2123
needs_processing = False
2224
needs_drawrect = True
@@ -140,7 +142,7 @@ def __init__(
140142

141143
def get_drawer(
142144
self, drawer: Union[QRModuleDrawer, str, None]
143-
) -> Optional[QRModuleDrawer]:
145+
) -> QRModuleDrawer | None:
144146
if not isinstance(drawer, str):
145147
return drawer
146148
drawer_cls, kwargs = self.drawer_aliases[drawer]

qrcode/image/pil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import qrcode.image.base
24
from PIL import Image, ImageDraw
35

qrcode/image/pure.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from itertools import chain
24

35
from qrcode.compat.png import PngWriter

qrcode/image/styledpil.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import qrcode.image.base
24
from PIL import Image
35
from qrcode.image.styles.colormasks import QRColorMask, SolidFillColorMask

0 commit comments

Comments
 (0)