|
19 | 19 |
|
20 | 20 | FuncType = Callable[..., Any] |
21 | 21 | F = TypeVar("F", bound=FuncType) |
22 | | -T = TypeVar("T") |
23 | 22 |
|
24 | 23 |
|
25 | 24 | def _deprecate_passthrough( |
@@ -61,7 +60,7 @@ def _check(error: int) -> int: |
61 | 60 | return error |
62 | 61 |
|
63 | 62 |
|
64 | | -def _check_p(pointer: T) -> T: |
| 63 | +def _check_p[T](pointer: T) -> T: |
65 | 64 | """Treats NULL pointers as errors and raises a libtcod exception.""" |
66 | 65 | if not pointer: |
67 | 66 | _raise_tcod_error() |
@@ -94,13 +93,13 @@ def _int(int_or_str: SupportsInt | str | bytes) -> int: |
94 | 93 | return int(int_or_str) |
95 | 94 |
|
96 | 95 |
|
97 | | -def _bytes(string: AnyStr) -> bytes: |
| 96 | +def _bytes(string: AnyStr) -> bytes: # noqa: UP047 |
98 | 97 | if isinstance(string, str): |
99 | 98 | return string.encode("utf-8") |
100 | 99 | return string |
101 | 100 |
|
102 | 101 |
|
103 | | -def _unicode(string: AnyStr, stacklevel: int = 2) -> str: |
| 102 | +def _unicode(string: AnyStr, stacklevel: int = 2) -> str: # noqa: UP047 |
104 | 103 | if isinstance(string, bytes): |
105 | 104 | warnings.warn( |
106 | 105 | "Passing byte strings as parameters to Unicode functions is deprecated.", |
@@ -129,8 +128,7 @@ def _path_encode(path: Path) -> bytes: |
129 | 128 | try: |
130 | 129 | return str(path).encode(locale.getlocale()[1] or "utf-8") # Stay classy, Windows |
131 | 130 | except UnicodeEncodeError as exc: |
132 | | - if sys.version_info >= (3, 11): |
133 | | - exc.add_note("""Consider calling 'locale.setlocale(locale.LC_CTYPES, ".UTF8")' to support Unicode paths.""") |
| 131 | + exc.add_note("""Consider calling 'locale.setlocale(locale.LC_CTYPES, ".UTF8")' to support Unicode paths.""") |
134 | 132 | raise |
135 | 133 |
|
136 | 134 |
|
|
0 commit comments