Commit Graph

62 Commits

Author SHA1 Message Date
Avasam
9c959a7dd3 Enable Ruff D (pydocstyle) with pep257 convention (#13326)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-01-02 22:05:35 +00:00
Sebastian Rittau
1fa4986f71 Move common utility functions to a common library (#12773) 2024-10-14 08:00:02 +02:00
Sebastian Rittau
6ba6589144 Support environment markers in requires fields (#12711) 2024-10-02 10:14:33 +02:00
Sebastian Rittau
3b385903a1 Pass Requirement objects around (#12709)
This allows us to keep metadata like python_version and platform_system
and use it to conditionally install packages.
2024-09-30 17:45:58 +02:00
Avasam
d34ef50754 Optional pytype install on Windows (no CI) (#12669) 2024-09-17 10:58:31 +02:00
Jan Kühle
99f6238b91 Update pytype to 2024.09.13 and Python 3.12 (#12653) 2024-09-13 14:01:46 +02:00
Jan Kühle
d326c9bd42 Filter pytype tests by stdlib/VERSIONS file (#12649)
Filter the files to run pytype tests on by stdlib/VERSIONS file. This
becomes important for Python 3.12, where e.g. checking asynchat.pyi
requires asyncore.pyi, both of which have been removed in 3.12.
2024-09-12 18:40:19 +02:00
Avasam
3719f02dbf Using precise code for pyright: ignore and re-enabling various pyright tests (#12576) 2024-08-22 03:34:52 +02:00
Sebastian Rittau
425c69a6b9 Prefix utility modules with underscore (#11999) 2024-05-22 09:35:11 -04:00
Avasam
da69247514 Code improvements from new Ruff checks (#11498) 2024-02-28 22:30:18 -08:00
Rebecca Chen
1ecaab1641 Run pytype_test in Python 3.11. (#10903)
As of version 2023.10.17, pytype now supports 3.11.
2023-10-18 00:44:14 +01:00
Alex Waygood
53422f8918 pytype_test.py: Handle non-typeshed requirements that are stub-only packages (#10723) 2023-09-20 20:03:01 +01:00
Alex Waygood
39fd112f3e Further improve non-types dependency handling in pytype_test.py (#10393) 2023-07-01 00:24:38 +01:00
Alex Waygood
7fdd05003a pytype_test.py: Use importlib.metadata instead of pkg_resources (#10391) 2023-06-30 21:37:06 +01:00
Sebastian Rittau
1e25866b23 Improve pytype compatibility handling (#10377) 2023-06-28 12:29:13 +02:00
Rebecca Chen
274f449edc Treat entries on pytype_exclude_list as missing modules for pytype_test. (#10187) 2023-05-17 00:38:49 +02:00
Avasam
14b06ae672 pytype_test.py: Fix typechecking errors following #9747 (#9849) 2023-03-06 18:23:07 +00:00
Avasam
75f47d0cb1 Typecheck typeshed's code with pyright (#9793)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
2023-02-22 18:53:07 +00:00
Alex Waygood
c216b74e39 Centralize METADATA.toml parsing in the test suite (#9534) 2023-01-28 15:13:46 +00:00
Alex Waygood
ab1921a737 Teach isort that imports from utils are first-party imports (#9500) 2023-01-11 17:25:32 +01:00
Rebecca Chen
622a96b1de pytype_test: Mark typeshed-external dependencies as missing. (#9486)
Co-authored-by: Avasam <samuel.06@hotmail.com>
2023-01-10 22:00:43 +00:00
hamdanal
6c32486971 pytype_test.py: fix f-string missing “f” (#9430) 2022-12-31 10:07:02 +00:00
Nikita Sobolev
bc1da6a748 Remove unused code from pytype_test.py (#9317) 2022-12-02 18:33:24 +00:00
Avasam
087917f2b8 Space out pytype errors (#9281) 2022-11-26 01:32:08 +01:00
Rebecca Chen
1e1a586893 Update pytype_test to be compatible with the latest pytype version. (#8551)
We moved some files around =)
2022-08-17 19:18:33 -07:00
Alex Waygood
4414246a15 Clean up a few Python 2 remnants (#8452) 2022-07-31 19:19:18 +01:00
Alex Waygood
78d96cd17e Drop support for Python 2 (#8272) 2022-07-12 09:08:56 +02:00
Alex Waygood
aa72cb1dcf Run pyupgrade on the tests directory (#7880) 2022-05-19 14:16:53 +01:00
Alex Waygood
8b118b236d Run mypy on the test cases and test scripts (#7746) 2022-04-30 06:39:07 -06:00
Alex Waygood
9d450cb50c Make test scripts pass mypy --strict (#7745)
- Add several type hints to untyped functions.
- While we're at it, upgrade several annotations to use modern syntax by using `from __future__ import annotations`. This means that the tests can't be run on Python 3.6, but 3.6 is EOL, and it is already the case that some scripts in this directory can only be run on more recent Python versions. E.g. `check_new_syntax.py` uses `ast.unparse`, which is only available in Python 3.9+.
- Fix a few pieces of code that didn't type check.
2022-04-29 21:55:12 -06:00
Rebecca Chen
f1856a384e pytype_test: Don't mix up stdlib and stub packages starting with stdlib. (#7609)
This should fix the pytype_test failure in
https://github.com/python/typeshed/pull/7608.
2022-04-08 13:01:37 -07:00
Jelle Zijlstra
1f1bc6f27c add pre-commit config (#6341)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Akuli <akuviljanen17@gmail.com>
2021-11-19 16:46:51 +02:00
Rebecca Chen
fac273a545 Stop using pytype.pytd.typeshed.get_python_major_versions. (#5941)
We deleted this method as part of our Python 2 cleanup efforts.
2021-08-19 18:36:19 -07:00
Rebecca Chen
4e228870bb Stop running pytype_test on Python 2-only stubs. (#5904)
pytype is finally dropping Python 2 support (in the upcoming release
after 2021.08.03), so pytype_test can no longer run with
--python_version=2.
2021-08-10 09:36:10 +02:00
Rebecca Chen
ce24720a1a Fix and re-enable pytype_test (#4975)
For now, the test requires changes that have been merged into the pytype master branch but not yet released. I'll update requirements-tests-py3.txt again once I've cut a new release (hopefully later this week).

* Fix pytype_test.
* Re-enable pytype_test.
* Remove continue-on-error from pytype_test.
* Temporarily install pytype from its master branch, as the code to
  support the new directory structure hasn't been released yet.
* Set TYPESHED_HOME before using pytype.pytd.Typeshed().
2021-01-27 22:00:27 +00:00
Rebecca Chen
a7c4663e39 Speed up pytype_test by reusing the pyi loader. (#4960)
I noticed that the pytype parse test was getting quite slow again. This
is a somewhat hacky change that caches pytype's internal pyi loader to
avoid parsing files multiple times. On my machine, the test goes from
taking ~6m to complete to ~30s.
2021-01-21 18:44:06 -08:00
Philipp Hahn
d4bd95fd86 Fix hard-coded pytype version (#4771)
[tests/pytype_test.py](./tests/pytype_test.py#L176) is still using
Python `3.6`:
> python_version="2.7" if version == 2 else "3.6",

The test fails to run if `python3.6` is unavailable (for example on
Debian 10 Buster, which has 3.7).

According to (https://devguide.python.org/#status-of-python-branches
`3.6` is still maintained until end of 2021.

`pytype` itself [claims](https://github.com/google/pytype#requirements)
to run on `2.7`, `3.5`-`3.8`.

Change the script to use the version of Python from the invoking
interpreter.
2020-11-16 11:08:42 -08:00
Shantanu
48970d31de tests / scripts: blacken and isort (#4704)
I often run black and isort in typeshed root and then have to undo these
changes.

Co-authored-by: hauntsaninja <>
2020-10-25 11:21:03 +01:00
Rebecca Chen
2587c93ff8 Stop passing python_exe to pytype_test. (#4488)
pytype hasn't needed the python_exe argument for a while, and getting
rid of it allows some code to be deleted.
2020-08-27 19:19:49 -07:00
wouter bolsterlee
3efb675dba Use ‘exclude list’ instead of ‘blacklist’ (#4297)
This replaces all uses of ‘blacklist’ with ‘exclude list’. Benefits:

- It is racially neutral terminology; see e.g. [1]

- It makes the meaning more clear. In fact, with the popular Python
  autoformatter called ‘black’, also used by this project, files can be
  ‘blackened’ which is something completely different from them being on
  a blacklist.

[1] https://chromium.googlesource.com/chromium/src/+/master/styleguide/inclusive_code.md#racially-neutral
2020-07-01 09:10:37 +02:00
Sebastian Rittau
b05adddf5a pytype tests: Specify files or dirs to check (#4279)
This adds the ability to check single files or directories with
tests/pytype_test.py by specifying the paths to check on the
command line.
2020-06-26 20:45:38 +02:00
Rune Tynan
2b8b116a19 Make PathMatcher correctly exclude paths on windows / any OS without / seperators (#3837) 2020-03-09 15:33:19 -07:00
Rune Tynan
6058c23136 Make path separator based on OS separator (#3375) 2019-10-16 10:12:45 -07:00
Rebecca Chen
c356316c6f Use pytype.config.Options.create() for prettier code. (#3151)
This is a small cosmetic change. I want to encourage use of the
nicer-lookng pytype.config.Options.create() rather than
direct construction of the command-line args, so I'm changing
over all occurrences of the latter that I can find.
2019-07-25 19:43:33 -07:00
Eric Arellano
1763f51c0d Refactor tests/pytype_test.py (#3065) 2019-06-19 15:19:10 -07:00
Rebecca Chen
4990830c8f Make pytype happy with the third_party click stubs. (#2966)
This also makes the flask stubs that depend on click parseable.

* In pytype_test, only parse files with the .pyi extension.
  (There's a README in third_party/2and3/click/.)
* Annotate with ContextManager rather than using the
  contextmanager decorator. This is shorter, removes a
  dependency, and gets rid of the slight weirdness of a
  decorator needing to be evaluated in a stub.
* Fix non-stub things.
2019-05-07 08:50:24 +02:00
Rebecca Chen
5081d1e132 Switch pytype_test from a whitelist to a blacklist for third_party. (#2956)
During the PyCon sprints, I'm planning to bash the pytype pyi
parser into shape so we can handle all of third_party. As a first
step, create an explicit blacklist of everything pytype chokes on.
2019-05-05 22:02:52 -04:00
Rebecca Chen
a651e2f3cd Update pytype_test to remove now-unnecessary parse-only functionality. (#2897)
With today's release, pytype is able to fully load
stdlib/3/collections/__init__.pyi, so the test no longer needs the
ability to partially parse stubs using the pytd tool. Removing this
functionality allows the test code to be simplified considerably.
2019-04-03 12:47:20 -07:00
Rebecca Chen
45e52de188 Speed up pytype_test by reducing subprocess calls. (#2868)
Speeds up pytype considerably by directly calling pytype.io.parse_pyi
rather than running `pytype --parse-pyi` in a subprocess.
The subprocess logic is still required to handle the one pyi file
marked `# parse only` in the pytype blacklist. Once
https://github.com/google/pytype/issues/242 is fixed, the test code
can be cleaned up considerably.
2019-03-14 19:04:40 -07:00
Sebastian Rittau
f07bdf418b Fix pytype test output (#2534) 2018-10-22 09:14:22 +02:00