-
-
Notifications
You must be signed in to change notification settings - Fork 8
added test of full command line use. #98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f228c26
added test of full command line use.
PythonCHB 642acbe
try patching ninja exe
ngam 62a2464
add patch
ngam 090b22b
Merge branch 'main' into main
ngam 40a7ea0
fix typo
ngam e21fe9e
Create remove-ninja-req.patch
ngam 141b6f0
Update meta.yaml
ngam 83f9241
fix indent
ngam dabe931
return list to be consistent
ngam 3d945da
only change when getting the ninja exe
ngam bb71424
remove from setup.cfg not reqs.txt
ngam f0b9e94
fix patch after feedback
ngam 86b3a71
fix patch again
ngam bb3a81f
typo
ngam 79812a8
modulenotfound
ngam 35ff226
better?
ngam 944bea3
import lib
ngam bf8da73
finally...
ngam 76a2a69
typo
ngam 2246cd4
format patch
ngam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| From 53db9310cca269d6c65ebaaf92f560879b4202f8 Mon Sep 17 00:00:00 2001 | ||
| From: ngam <67342040+ngam@users.noreply.github.com> | ||
| Date: Tue, 21 Feb 2023 22:53:58 -0500 | ||
| Subject: [PATCH] use ninja importability when python-ninja isn't available | ||
|
|
||
| --- | ||
| pytype/tools/analyze_project/pytype_runner.py | 4 +++- | ||
| 1 file changed, 3 insertions(+), 1 deletion(-) | ||
|
|
||
| diff --git a/pytype/tools/analyze_project/pytype_runner.py b/pytype/tools/analyze_project/pytype_runner.py | ||
| index 9d09d8d0..c4579978 100644 | ||
| --- a/pytype/tools/analyze_project/pytype_runner.py | ||
| +++ b/pytype/tools/analyze_project/pytype_runner.py | ||
| @@ -1,5 +1,6 @@ | ||
| """Use pytype to analyze and infer types for an entire project.""" | ||
|
|
||
| +import importlib | ||
| import collections | ||
| import itertools | ||
| import logging | ||
| @@ -46,7 +47,8 @@ def _get_executable(binary, module=None): | ||
| path_utils.abspath(path_utils.dirname(custom_bin)), | ||
| 'pytype-single') | ||
| ]) | ||
| - if sys.executable is not None: | ||
| + importable = importlib.util.find_spec(module or binary) | ||
| + if sys.executable is not None and importable is not None: | ||
| return [sys.executable, '-m', module or binary] | ||
| else: | ||
| return [binary] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/setup.cfg b/setup.cfg | ||
| --- setup.cfg | ||
| +++ setup.cfg | ||
| @@ -35,9 +35,8 @@ | ||
| importlab>=0.8 | ||
| jinja2>=3.1.2 | ||
| libcst>=0.4.9 | ||
| networkx<2.8.4 | ||
| - ninja>=1.10.0.post2 | ||
| pydot>=1.4.2 | ||
| tabulate>=0.8.10 | ||
| toml>=0.10.2 | ||
| typed_ast>=1.5.0; python_version < '3.8' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| """ | ||
| A short script to run pytype with a real file to check | ||
|
|
||
| This should catch whether you can actually run pytype | ||
|
|
||
| (in particular if pytypw works with the conda-installed ninja) | ||
|
|
||
| NOTE: I suppose it would be more robust to see if it actually | ||
| does the check correctly, but that's really pytype's problem | ||
| """ | ||
| import sys | ||
| import subprocess | ||
| from pathlib import Path | ||
|
|
||
| TEST_FILE = """ | ||
|
|
||
| def fun(x: int): | ||
| return x * 2 | ||
|
|
||
| # this should type check with no errors | ||
| y = fun(2) | ||
|
|
||
| # this should type check with an error | ||
| # z = fun(2.0) | ||
| """ | ||
|
|
||
| filepath = Path("python_test_file.py") | ||
|
|
||
| with open(filepath, 'w', encoding='utf-8') as pyfile: | ||
| pyfile.write(TEST_FILE) | ||
|
|
||
| try: | ||
| subprocess.check_call(("pytype", str(filepath))) | ||
| # it worked | ||
| sys.exit(0) | ||
| except subprocess.CalledProcessError: | ||
| # something went wrong | ||
| print("Something went wrong running pytype") | ||
| raise | ||
| finally: | ||
| filepath.unlink(missing_ok=False) | ||
|
|
||
|
|
||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eli-schwartz I hope you're damn proud of this 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is a pretty good idea, yes.