Skip to content

Commit acd7721

Browse files
authored
Fix type checking issues from latest pyright (#11)
* avoiding typevar guarding error * switch to released python 3.12
1 parent 9e36fa6 commit acd7721

File tree

6 files changed

+8
-9
lines changed

6 files changed

+8
-9
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
17-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12-dev']
17+
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
1818

1919
steps:
2020
- uses: actions/checkout@v3

.vscode/settings.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
"msrc-appconfig-param"
99
],
1010
"python.testing.pytestEnabled": true,
11-
"python.linting.flake8Enabled": true
1211
}

msrc-appconfig/msrc/appconfig/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations
2-
from typing import Any, Dict, Generator, List, Mapping, Optional
2+
from typing import Dict, Generator, List, Mapping, Optional
33
from typing import Sequence, Tuple, Type, TypeVar, Union
44
"""Flexible typed application configuration."""
55
import itertools
@@ -38,7 +38,7 @@
3838
"to_argv"
3939
]
4040

41-
AppConfig = TypeVar('AppConfig', bound=Any)
41+
AppConfig = TypeVar('AppConfig')
4242

4343

4444
class _SharedInstance:

msrc-appconfig/msrc/appconfig/read_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from msrc.appconfig.read_argv import from_argv as _from_argv
1717

1818

19-
AppConfig = ty.TypeVar('AppConfig', bound=ty.Any)
19+
AppConfig = ty.TypeVar('AppConfig')
2020

2121

2222
def gather(

msrc-appconfig/msrc/appconfig/schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def type_str(self) -> str:
325325

326326
SchemaSource = Tuple[Tuple[str, Element], ...]
327327

328-
AppConfig = TypeVar("AppConfig", bound=Any, covariant=True)
328+
AppConfig = TypeVar("AppConfig", covariant=True)
329329

330330

331331
class Schema(Dict[str, Element], Generic[AppConfig]):

msrc-appconfig/msrc/appconfig_decl/decl_namedtuples.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22
"""Provides appconfig support for typing.NamedTuple"""
3-
from typing import Mapping, NamedTuple, Optional, TYPE_CHECKING
3+
from typing import Mapping, NamedTuple, Optional, TYPE_CHECKING, cast
44
if TYPE_CHECKING:
55
from typing_extensions import TypeGuard
66
from msrc.appconfig.schema import Element, SchemaSource, interpret_type
@@ -9,8 +9,8 @@
99
def is_typed_named_tuple(appconfig: object) -> TypeGuard[NamedTuple]:
1010
return isinstance(appconfig, type) \
1111
and issubclass(appconfig, tuple) \
12-
and hasattr(appconfig, "_fields") \
13-
and hasattr(appconfig, "__annotations__") \
12+
and hasattr(cast(object, appconfig), "_fields") \
13+
and hasattr(cast(object, appconfig), "__annotations__") \
1414
and (len(appconfig._fields) == # type: ignore
1515
len(appconfig.__annotations__))
1616

0 commit comments

Comments
 (0)