Conversation
| "getfslineno", | ||
| "getrawcode", | ||
| "Traceback", | ||
| "TracebackEntry", |
There was a problem hiding this comment.
TracebackEntry is exposed through Traceback so it should be visible too (though this is an internal package anyway).
|
|
||
| @property | ||
| def path(self): | ||
| def path(self) -> Union[py.path.local, str]: |
There was a problem hiding this comment.
Code.path has this annoying type due to some error path, we should fix it sometime...
| self._conftestpath2mod = {} # type: Dict[Any, object] | ||
| # State related to local conftest plugins. | ||
| self._dirpath2confmods = {} # type: Dict[py.path.local, List[types.ModuleType]] | ||
| self._conftestpath2mod = {} # type: Dict[Path, types.ModuleType] |
There was a problem hiding this comment.
Actually stores Path and not what the previous comment said.
I removed the comments since they are redundant with the types.
| assert isinstance(modname, str), ( | ||
| "module name as text required, got %r" % modname | ||
| ) | ||
| modname = str(modname) |
There was a problem hiding this comment.
Not needed per assert above.
| """ | ||
|
|
||
| args = attr.ib(converter=tuple) | ||
| args = attr.ib(type=Tuple[str, ...], converter=_args_converter) |
There was a problem hiding this comment.
Explicit converter instead of tuple needed just for the type annotation to work
|
|
||
| def _strtobool(val): | ||
| """Convert a string representation of truth to true (1) or false (0). | ||
| def _strtobool(val: str) -> bool: |
There was a problem hiding this comment.
Changed _strtobool to return bool instead of 0/1, seems more sensible.
|
|
||
| if auto_indent_option is None: | ||
| return 0 | ||
| elif type(auto_indent_option) is int: |
There was a problem hiding this comment.
mypy doesn't do type narrowing on type(...) is .., so I changed the code to use isinstance instead. Then things need to move a bit because isinstance(True, int) is true.
| raise ConftestImportFailure(path, sys.exc_info()) from e | ||
| except Exception as exc: | ||
| assert exc.__traceback__ is not None | ||
| exc_info = (type(exc), exc, exc.__traceback__) |
There was a problem hiding this comment.
This is needed because sys.exc_info() has types with BaseException while we want just Exception.
nicoddemus
left a comment
There was a problem hiding this comment.
LGTM, thanks for the hardworking here!
src/_pytest/config/__init__.py
Outdated
|
|
||
|
|
||
| def _get_plugin_specs_as_list(specs): | ||
| def _get_plugin_specs_as_list(specs) -> List[str]: |
There was a problem hiding this comment.
I'm curious, don't we need to type specs here?
There was a problem hiding this comment.
I added another commit which does this now, but it also refactors the function a bit. I was thrown off by the ModuleType check but found the reference issue.
This improves the typing around
_pytest.config, and also makes pytest completely clean with regards to the py typings in pytest-dev/py#232.