Commit Graph

209 Commits

Author SHA1 Message Date
Ran Benita d1ee6d154f Enable flake8-pie 2024-02-09 11:08:33 +02:00
Pierre Sassoulas e193a263c7 [flake8-pyi] Add checks for flake8-pyi and fix existing 2024-02-04 19:27:23 +01:00
Pierre Sassoulas 180a16a344 [ruff] Fix ambiguous characters found in string and comment 2024-02-02 15:18:38 +01:00
Pierre Sassoulas 514376fe29 [ruff] Add ruff's check and autofix existing issues 2024-02-02 15:18:38 +01:00
Pierre Sassoulas 4588653b24 Migrate from autoflake, black, isort, pyupgrade, flake8 and pydocstyle, to ruff
ruff is faster and handle everything we had prior.

isort configuration done based on the indication from
https://github.com/astral-sh/ruff/issues/4670, previousely based on
reorder-python-import (#11896)

flake8-docstrings was a wrapper around pydocstyle (now archived) that
explicitly asks to use ruff in https://github.com/PyCQA/pydocstyle/pull/658.

flake8-typing-import is useful mainly for project that support python 3.7
and the one useful check will be implemented in https://github.com/astral-sh/ruff/issues/2302

We need to keep blacken-doc because ruff does not handle detection
of python code inside .md and .rst. The direct link to the repo is
now used to avoid a redirection.

Manual fixes:
- Lines that became too long
- % formatting that was not done automatically
- type: ignore that were moved around
- noqa of hard to fix issues (UP031 generally)
- fmt: off and fmt: on that is not really identical
  between black and ruff
- autofix re-order in pre-commit from faster to slower

Co-authored-by: Ran Benita <ran@unusedvar.com>
2024-02-02 09:27:00 +01:00
Bruno Oliveira 878af85aef
mypy: disallow untyped defs by default (#11862)
Change our mypy configuration to disallow untyped defs by default, which ensures *new* files added to the code base are fully typed.

To avoid having to type-annotate everything now, add `# mypy: allow-untyped-defs` to files which are not fully type annotated yet.

As we fully type annotate those modules, we can then just remove that directive from the top.
2024-01-28 10:12:42 -03:00
Ran Benita acd445a3f3
Merge pull request #11646 from bluetech/pkg-collect
Rework Session and Package collection
2023-12-30 12:51:48 +02:00
Benjamin Schubert 88ae27da08
Add syntactic highlights to the error explanations (#11661)
* Put a 'reset' color in front of the highlighting

When doing the highlighting, some lexers will not set the initial color
explicitly, which may lead to the red from the errors being propagated
to the start of the expression

* Add syntactic highlighting to the error explanations

This updates the various error reporting to highlight python code when
displayed, to increase readability and make it easier to understand
2023-12-21 17:11:56 +00:00
Ran Benita 385796ba49 Rework Session and Package collection
Fix #7777.
2023-12-10 17:01:39 +02:00
Benjamin Schubert a536f49d91
Separate the various parts of the error report with newlines (#11659)
Previously the error report would have all sections glued together:

- The assertion representation
- The error explanation
- The full diff

This makes it hard to see at a glance where which one starts and ends.

One of the representation (dataclasses, tuples, attrs) does display a
newlines at the start already.

Let's add a newlines before the error explanation and before the full
diff, so we get an easier to read report.

This has one disadvantage: we get one line less in the least verbose
mode, where the output gets truncated.
2023-12-06 09:25:00 +00:00
Benjamin Schubert 2d1710e0e9
Improve the full diff by having more consistent indentation in the PrettyPrinter (#11571)
The normal default pretty printer is not great when objects are nested
and it can get hard to read the diff.

Instead, provide a pretty printer that behaves more like when json get
indented, which allows for smaller, more meaningful differences, at
the expense of a slightly longer diff.

This does not touch the other places where the pretty printer is used,
and only updated the full diff one.
2023-11-27 16:47:18 +02:00
Patrick Lannigan 9dc1fc4523
Add verbosity_assertions and config.get_verbosity
Fixes #11387
2023-11-19 11:56:29 -03:00
Benjamin Schubert fbe3e29a55
Color the full diff that pytest shows as a diff (#11530)
Related to #11520
2023-10-24 08:42:21 -03:00
Reagan Lee 9bbfe995ee
Add more comprehensive set assertion rewrites (#11469)
Fixes #10617
2023-10-02 18:37:52 -03:00
Zac Hatfield-Dodds f4e3b4ad98 Drop Python 3.7 2023-06-30 14:55:42 -07:00
Zac Hatfield-Dodds 661b938fca Add encoding in more tests 2023-06-20 04:55:40 -07:00
Pierre Sassoulas b31db4809b
Avoid truncation when truncating means longer output (#10446)
Fixes #6267
2022-12-17 10:24:46 -03:00
Daniel Valenzuela b55e264a67 Fix test_raising_repr test
Closes #10473

Python <3.11 versions depend on `exceptiongroup>=1.0.0rc8`, and they released version `1.0.1`
6 days ago (2022/11/03) that as a side-effect changed the output of exceptions.
2022-11-09 19:43:10 -03:00
itxasos23 78c2c48c67
Handle NFC/NFD strings that normalize to the same string. (#10355)
Co-authored-by: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
2022-10-09 17:09:33 -07:00
Anthony Sottile 8fa775bcee fix comparison of dataclasses with `InitVar` 2022-04-08 19:51:05 -04:00
Samuel Colvin b75cbee290
Remove newlines from left/right operands with '-vv' (#9743)
The left/right operands produced when `verbose > 1` should not contain newlines, because they are used to 
build the `summary` string. The `assertrepr_compare` function returns a list of lines, and the summary is one of those lines and should not contain newlines itself. 

Fix #9742

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Bruno Oliveira <nicoddemus@gmail.com>
2022-03-19 11:55:39 +00:00
Bruno Oliveira fac8f284cd
Fix diff output for data types where `-v` would show less information (#9661)
Close #5192
2022-02-15 09:43:20 -03:00
Bruno Oliveira b79eff065e
Enable testing with Python 3.11 (#9511) 2022-02-11 15:20:42 +00:00
Hugo van Kemenade 61417b2551 Drop support for EOL Python 3.6 2021-12-30 13:25:34 +02:00
Yuval Shimon 0ea039db60 adding auto_detect=true test 2021-12-12 16:11:33 +02:00
Yuval Shimon 0c45065040 removing coverage on eq method 2021-12-12 15:39:30 +02:00
Yuval Shimon 897395afd5 fix 9326 2021-12-12 14:38:45 +02:00
David Szotten d5c020d8c5 always show full diff in ci
follow-up to #1314, for similar reasons

closes #9023
2021-08-19 20:17:43 +01:00
Karthikeyan Singaravelan 9a0f4e57ee Add support to display field names in namedtuple diffs. 2020-10-31 14:41:53 +02:00
Christine Mecklenborg 47ff911c8f Migrate test_assertion.py from testdir to pytester 2020-10-29 20:39:44 -05:00
Anthony Sottile 33d119f71a py36+: com2ann 2020-10-05 18:33:17 -07:00
Anthony Sottile 66bd44c13a py36+: pyupgrade: py36+ 2020-10-03 12:46:54 -07:00
Anthony Sottile 53b5f64b4b py36+: resolve py36 TODOs 2020-10-02 19:57:55 -07:00
Ran Benita 32bb8f3a63 Bump attrs requirement from >=17.4.0 to >=19.2.0
This allows us to remove the `ATTRS_EQ_FIELD` thing which is causing
some annoyance.
2020-09-27 13:17:59 +03:00
Ran Benita b8471aa527 testing: fix some docstring issues
In preparation for enforcing some docstring lints.
2020-08-03 10:10:43 +03:00
Ran Benita be656dd4e4 typing: set disallow_any_generics
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-01 20:39:15 +03:00
Vlad-Radz 678c1a0745
assertion: improve diff output of recursive dataclass/attrs
Co-authored-by: Vlad <uladzislau.radziuk@nordcloud.com>
2020-07-08 19:04:56 +03:00
Gleb Nikonorov 33de350619 parametrize test_warn_missing for a cleaner test 2020-06-21 10:26:36 -04:00
Gleb Nikonorov fe68c58698 add test_warn_missing case for --assert=plain 2020-06-20 13:06:41 -04:00
Gleb Nikonorov a9d50aeab6 remove extra whitespace 2020-06-20 12:18:55 -04:00
Gleb Nikonorov ac89d6532a replace stderr warnings with the warnings module 2020-06-20 12:15:58 -04:00
Bruno Oliveira c229d6f46f Fix mypy checks 2020-06-09 14:48:49 -03:00
Ran Benita 09988f3ed1 Update testing/test_assertion.py 2020-06-09 14:39:40 -03:00
ibriquem e2e7f15b71 Make dataclasses/attrs comparison recursive, fixes #4675 2020-06-09 14:39:40 -03:00
Ran Benita 54ad048be7 Enable check_untyped_defs mypy option for testing/ too 2020-06-05 11:34:20 +03:00
Ran Benita 20956b2f4e Remove some no-longer-needed compat code in test_assertion 2020-04-08 21:35:42 +03:00
Daniel Hahler 48c9f556ef
Fix tests: use explicit syspathinsert where tests might hang (#7008)
Use `testdir.syspathinsert()` with multiprocessing tests:

- test_chained_exceptions_no_reprcrash
- test_exception_handling_no_traceback

This only works currently because `_importtestmodule` changes `sys.path`
as a side-effect.

It appears to be only required on Windows though - likely due to the
multiprocessing method used there.
2020-04-04 12:33:15 +02:00
Daniel Hahler bce1d40fb0
tests: harden test_reprcompare_notin, factor out callop (#6764)
* tests: assertion: factor out `callop`, typing

* tests: harden test_reprcompare_notin
2020-03-08 01:23:19 +01:00
Daniel Hahler 6a7df7f031
test_assertion: harden/improve test_{text_diff,unicode} (#6806) 2020-02-24 15:19:08 +01:00
Daniel Hahler 1baeefc2fd test_reprcompare_whitespaces: use callequal 2020-02-22 13:15:17 +01:00