-
-
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 14 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,27 @@ | ||
| diff --git a/pytype/tools/analyze_project/pytype_runner.py b/pytype/tools/analyze_project/pytype_runner.py | ||
| --- pytype/tools/analyze_project/pytype_runner.py | ||
| +++ pytype/tools/analyze_project/pytype_runner.py | ||
| @@ -45,12 +45,20 @@ | ||
| path_utils.join( | ||
| path_utils.abspath(path_utils.dirname(custom_bin)), | ||
| 'pytype-single') | ||
| ]) | ||
| - if sys.executable is not None: | ||
| - return [sys.executable, '-m', module or binary] | ||
| + elif binary == 'ninja': | ||
| + try: | ||
| + import ninja | ||
| + to_return = [sys.executable, '-m', module or binary] | ||
| + except ImportError: | ||
| + to_return = [binary] | ||
| + return to_return | ||
| else: | ||
| - return [binary] | ||
| + if sys.executable is not None: | ||
| + return [sys.executable, '-m', module or binary] | ||
| + else: | ||
| + return [binary] | ||
| PYTYPE_SINGLE = _get_executable('pytype-single', 'pytype.single') | ||
|
|
||
|
|
||
| def resolved_file_to_module(f): | ||
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.
The diff hunk would be slightly smaller here if you preserved the indentation for the sys.executable check and just switched it to an elif, rather than nesting it inside of an else.
That's really just style, so it doesn't matter one way or another, just thought I'd mention it.
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.
Ugh, something isn't working...
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.
what in this is returning a None? I had a loooooong day... :(
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.
(Will incorporate your suggestion once confirmed to work btw)