Age | Commit message (Collapse) | Author |
|
* [pre-commit.ci] pre-commit autoupdate
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* manual fixes after configuration update
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Anthony Sottile <asottile@umich.edu>
|
|
|
|
|
|
Make the objects more light weight.
Remove unused properties.
|
|
|
|
|
|
|
|
|
|
|
|
py36+: remove workaround for Union[Pattern/Match] bug
|
|
|
|
automated with:
```bash
git grep -l 'from .* import TYPE_CHECKING' |
xargs reorder-python-imports \
--application-directories .:src \
--remove-import 'from _pytest.compat import TYPE_CHECKING' \
--add-import 'from typing import TYPE_CHECKING'
```
|
|
This allows us to remove the `ATTRS_EQ_FIELD` thing which is causing
some annoyance.
|
|
This indicates at least for people using type checkers that these
classes are not designed for inheritance and we make no stability
guarantees regarding inheritance of them.
Currently this doesn't show up in the docs. Sphinx does actually support
`@final`, however it only works when imported directly from `typing`,
while we import from `_pytest.compat`.
In the future there might also be a `@sealed` decorator which would
cover some more cases.
|
|
|
|
Fix #7707
|
|
We used it as a shortcut for avoiding coverage, but pylint has a special
interpretation of it as an abstract method which we don't want.
|
|
|
|
This makes mypy raise an error whenever it detects code which is
statically unreachable, e.g.
x: int
if isinstance(x, str):
... # Statement is unreachable [unreachable]
This is really neat and finds quite a few logic and typing bugs.
Sometimes the code is intentionally unreachable in terms of types, e.g.
raising TypeError when a function is given an argument with a wrong
type. In these cases a `type: ignore[unreachable]` is needed, but I
think it's a nice code hint.
|
|
This prevents referring to a generic type without filling in its generic
type parameters.
The FixtureDef typing might need some more refining in the future.
|
|
|
|
In Python, if module A defines a name `name`, and module B does `import
name from A`, then another module C can `import name from B`.
Sometimes it is intentional -- module B is meant to "reexport" `name`.
But sometimes it is just confusion/inconsistency on where `name` should
be imported from.
mypy has a flag `--no-implicit-reexport` which puts some order into
this. A name can only be imported from a module if
1. The module defines the name
2. The module's `__all__` includes the name
3. The module imports the name as `from ... import .. as name`.
This flag is included in mypy's `--strict` flag.
I like this flag, but I realize it is a bit controversial, and in
particular item 3 above is a bit unfriendly to contributors who don't
know about it. So I didn't intend to add it to pytest.
But while investigating issue 7589 I came upon mypy issue 8754 which
causes `--no-implicit-reexport` to leak into installed libraries and
causes some unexpected typing differences *in pytest* if the user uses
this flag.
Since the diff mostly makes sense, let's just conform to it.
|
|
* Revert change to traceback repr
* Add test and changelog entry
* Restore *exact* prev output
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
|
|
|
|
This implementation is the default when __eq__ is implemented.
|
|
Not used.
|
|
Really odd one, let's just inline it.
|
|
|
|
It does the same as a simple isinstance check, but adds a little layer
of obscurity on top, which the type checker can't penetrate.
|
|
The recursive way in which Source and getsource interact is a bit
confusing, just inline it.
|
|
A lot of complex code that isn't used anymore outside of tests after
the previous commit.
|
|
|
|
|
|
Cross-type comparisons like this are a bad idea. This isn't used.
|
|
It isn't used, so keep it simple.
|
|
inspect.getsource() definitely returns str.
|
|
This has been there since as far as the git history goes (2007), is not
covered by any test, and says "Buggy python version consider upgrading".
Hopefully everyone have upgraded...
|
|
Not used, except in tests.
|
|
Probably was done to avoid the shadowing issue, but work around it
instead.
|
|
|
|
|
|
Fix #5821
Co-authored-by: Ran Benita <ran@unusedvar.com>
|
|
Also switch to using ExceptionRepr instead of
`Union[ReprExceptionInfo, ExceptionChainRepr]`
which is somewhat annoying and less future proof.
|
|
|
|
|
|
|
|
`str(self.path)` can't raise at all, so it can just be removed.
|
|
|
|
Mostly I wanted to remove uses of `noqa`.
In Python 3 the two are the same.
|
|
These two files were really intertwined. Make it so code.py depends on
source.py without a reverse dependency.
No functional changes.
|