summaryrefslogtreecommitdiff
path: root/src/_pytest/_code
AgeCommit message (Collapse)Author
2020-12-30[pre-commit.ci] pre-commit autoupdate (#8201)pre-commit-ci[bot]
* [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>
2020-12-22code: convert from py.path to pathlibRan Benita
2020-10-31code: simplify Code constructionRan Benita
2020-10-31code: use properties for derived attributes, use slotsRan Benita
Make the objects more light weight. Remove unused properties.
2020-10-05py36+: com2annAnthony Sottile
2020-10-03py36+: pyupgrade: py36+Anthony Sottile
2020-10-03py36+: remove rexport of Path and PurePathAnthony Sottile
2020-10-03py36+: remove _pytest.compat.overloadAnthony Sottile
2020-10-02py36+: from typing import Type: no longer need guardAnthony Sottile
2020-10-02Merge pull request #7837 from asottile/py36_union_pattern_matchAnthony Sottile
py36+: remove workaround for Union[Pattern/Match] bug
2020-10-02py36+: remove workaround for Union[Pattern/Match] bugAnthony Sottile
2020-10-02py36+: remove TYPE_CHECKING from _pytest.compatAnthony Sottile
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' ```
2020-09-27Bump attrs requirement from >=17.4.0 to >=19.2.0Ran Benita
This allows us to remove the `ATTRS_EQ_FIELD` thing which is causing some annoyance.
2020-09-22Mark some public and to-be-public classes as `@final`Ran Benita
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.
2020-09-11Fix INTERNALERROR when accessing locals / globals with faulty `exec`Anthony Sottile
2020-09-03Fix handle of exceptions in ReprEntry with tb=lineBruno Oliveira
Fix #7707
2020-08-14Don't use NotImplementedError in `@overload`sRan Benita
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.
2020-08-06Replace some usages of py.path.localRan Benita
2020-08-04typing: set warn_unreachableRan Benita
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.
2020-08-01typing: set disallow_any_genericsRan Benita
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.
2020-08-01Format docstrings in a consistent styleRan Benita
2020-07-31typing: set no_implicit_reexportRan Benita
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.
2020-07-24Revert change to traceback repr (#7535)Zac Hatfield-Dodds
* Revert change to traceback repr * Add test and changelog entry * Restore *exact* prev output Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2020-07-15Clearer guidance on pytest.raise(match=...) failure (#7499)Lewis Cowles
2020-07-10code/code: remove redundant __ne__ implementationRan Benita
This implementation is the default when __eq__ is implemented.
2020-07-10code/code: remove Frame.exec_() methodRan Benita
Not used.
2020-07-10code/code: remove Frame.is_true() methodRan Benita
Really odd one, let's just inline it.
2020-07-10code/code: type annotations & doc cleanupsRan Benita
2020-07-10Stop using ExceptionInfo.errisinstance internallyRan Benita
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.
2020-07-01code/source: inline getsource()Ran Benita
The recursive way in which Source and getsource interact is a bit confusing, just inline it.
2020-07-01code/source: remove compiling functionsRan Benita
A lot of complex code that isn't used anymore outside of tests after the previous commit.
2020-07-01code/source: remove unused method Source.putaround()Ran Benita
2020-07-01code/source: remove unused method Source.isparseable()Ran Benita
2020-07-01code/source: remove support for comparing Source with strRan Benita
Cross-type comparisons like this are a bad idea. This isn't used.
2020-07-01code/source: remove support for passing multiple parts to SourceRan Benita
It isn't used, so keep it simple.
2020-07-01code/source: remove unneeded assertRan Benita
inspect.getsource() definitely returns str.
2020-07-01code/source: remove old IndentationError workaround in getsource()Ran Benita
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...
2020-07-01code/source: remove Source(deindent: bool) parameterRan Benita
Not used, except in tests.
2020-07-01code/source: expose deindent kwarg in signatureRan Benita
Probably was done to avoid the shadowing issue, but work around it instead.
2020-06-22config: improve typingRan Benita
2020-06-19Fix exception causes all over the codebaseRam Rachum
2020-06-13Introduce --import-mode=importlib (#7246)Bruno Oliveira
Fix #5821 Co-authored-by: Ran Benita <ran@unusedvar.com>
2020-06-12hookspec: type annotate pytest_internalerrorRan Benita
Also switch to using ExceptionRepr instead of `Union[ReprExceptionInfo, ExceptionChainRepr]` which is somewhat annoying and less future proof.
2020-06-05Improve types around repr_failure()Ran Benita
2020-06-05Enable check_untyped_defs mypy option for testing/ tooRan Benita
2020-05-30Issue 1316 - longrepr is a string when pytrace=False (#7100)Katarzyna Król
2020-05-28code: remove last usage of py.errorRan Benita
`str(self.path)` can't raise at all, so it can just be removed.
2020-05-12Remove no longer needed noqa'sRan Benita
2020-05-12Replace bare `except`s with `except BaseException`Ran Benita
Mostly I wanted to remove uses of `noqa`. In Python 3 the two are the same.
2020-05-06code: fix import cycles between code.py and source.pyRan Benita
These two files were really intertwined. Make it so code.py depends on source.py without a reverse dependency. No functional changes.