Commit Graph

46 Commits

Author SHA1 Message Date
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
Rebecca Chen
eb09e2898b Update pytype_test to be easier to run manually. (#2469)
* Moves the pytype installation to requirements-tests-py3.txt, now
  that pytype can run under Python 3.5+.
* Changes tests/pytype_test.py to not require a --python{version}-exe
  argument when it can automatically find the Python interpreter, and
  cleans up a few typos and out-of-date things.
* Updates the appropriate documentation.
* Updates .travis.yml.
2018-09-21 09:38:33 -07:00
Rebecca Chen
a08c6eae23 Add two more third_party libraries to pytype_test. (#2437) 2018-09-07 23:42:24 -07:00
Rebecca Chen
ff821f9751 Update pytype_test and pytype_blacklist (#2225)
* Add parts of third_party/ to pytype_test.

Pytype uses six and mypy_extensions, so these pyi files should be
tested with pytype.

* Remove newly loadable pyi files from pytype_blacklist.
2018-06-15 07:53:17 -07:00
Martin DeMello
caff008ff2 test files under stdlib/2and3 with both python versions (#2222)
* test files under stdlib/2and3 with both python versions
2018-06-12 15:48:00 -07:00
Jelle Zijlstra
cd4a5ff65c use pytype-single rather than pytype (#2198)
Looks like this happened in 3de774361b.
2018-06-05 08:34:21 -07:00
Martin DeMello
b0d5a2100e add progress monitoring (#1945) 2018-03-08 15:37:45 -08:00
Martin DeMello
754789b031 modify pytype_test to run from within pytype too, and support python3 (#1817) 2018-01-22 12:18:58 -08:00
Matthias Kramm
72052d8338 Fix tests to work with newest version of pytype (#1824) 2018-01-12 12:28:19 -08:00
Sebastian Steenbuck
8b56c1e59a Add all the files which pytype fails on during import. (#1720)
All of these files can not be used with pytype at HEAD. They fail during import with various error messages. Make the test script actually load the files and all dependencies of it, instead of just verifying that it can be parsed.

This list was generated by running pytype with more options.
1: typeshed-location was pointed to the current typeshed instead of the one shipped with pytype.
2: --module-name=<foo> was provided as a parameter. Without this parameter wildcard imports "from _ast import *" misbehave.

Files with a "# parse only" comment will only be parsed and not loaded.
2017-11-15 06:29:07 -08:00
Matthias Kramm
d7d27647a9 also run pytype tests for Python 3 modules (#1278) 2017-05-20 09:10:14 -07:00
Matthias Kramm
a2559eeaeb make pytype aware that 2.7/ has been renamed to 2/ (#729) 2016-12-02 06:10:14 -08:00
alvarocaceres
63cbe2dc3c Refactor how test are run, add tests to exercise pytype (if installed) (#353) 2016-07-12 15:30:54 -07:00