pytest-dev / py

Python development support library (note: maintenance only)
MIT License
68 stars 104 forks source link

typing: fix _SectionWrapper.items: uses str for values always #255

Closed blueyed closed 4 years ago

bluetech commented 4 years ago

Oops, forgot also

 class IniConfig:
     path: Final[str]
-    sections: Final[Mapping[str, Mapping[str, Optional[str]]]]
+    sections: Final[Mapping[str, Mapping[str, str]]]
blueyed commented 4 years ago

@bluetech Thanks for reviewing - your (first) patch (at least) does not apply to the PR branch. Please just push it yourself here.

bluetech commented 4 years ago

Sorry, it never works for me. Here is the diff again:

diff --git a/py/iniconfig.pyi b/py/iniconfig.pyi
index 6ed529c4..29332247 100644
--- a/py/iniconfig.pyi
+++ b/py/iniconfig.pyi
@@ -14,18 +14,18 @@ class _SectionWrapper:
     config: Final[IniConfig]
     name: Final[str]
     def __init__(self, config: IniConfig, name: str) -> None: ...
-    def __getitem__(self, key: str) -> Optional[str]: ...
+    def __getitem__(self, key: str) -> str: ...
     def __iter__(self) -> Iterator[str]: ...
-    def get(self, key: str, default: _D = ..., convert: Callable[[Optional[str]], _T] = ...) -> Union[_T, _D]: ...
+    def get(self, key: str, default: _D = ..., convert: Callable[[str], _T] = ...) -> Union[_T, _D]: ...
     def items(self) -> Iterator[Tuple[str, str]]: ...
     def lineof(self, name: str) -> Optional[int]: ...

 class IniConfig:
     path: Final[str]
-    sections: Final[Mapping[str, Mapping[str, Optional[str]]]]
+    sections: Final[Mapping[str, Mapping[str, str]]]
     def __init__(self, path: str, data: Optional[str] = None): ...
     def __contains__(self, arg: str) -> bool: ...
     def __getitem__(self, name: str) -> _SectionWrapper: ...
     def __iter__(self) -> Iterator[_SectionWrapper]: ...
-    def get(self, section: str, name: str, default: _D = ..., convert: Callable[[Optional[str]], _T] = ...) -> Union[_T, _D]: ...
+    def get(self, section: str, name: str, default: _D = ..., convert: Callable[[str], _T] = ...) -> Union[_T, _D]: ...
     def lineof(self, section: str, name: Optional[str] = ...) -> Optional[int]: ...
bluetech commented 4 years ago

Thanks!