Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
e4b5274
Simplify find_module cache and document PEP 561
emmatyping Dec 14, 2017
6b6a97d
More work on PEP 561 impl
emmatyping Dec 15, 2017
2c936e1
Scaffold testing and fix bugs.
emmatyping Dec 16, 2017
8f64f81
Add python arg for find_module
emmatyping Dec 17, 2017
ddc526f
Get packages from Python executables
emmatyping Dec 17, 2017
329dc68
Add support for non-running Python, fix bug in impl
emmatyping Dec 21, 2017
eba98d4
Merge branch 'master' of https://github.com/python/mypy into pep561-impl
emmatyping Dec 21, 2017
5576629
Fix mypy self check
emmatyping Dec 21, 2017
2397763
Fix weird subprocess bug that works in pydevd, but not otherwise
emmatyping Dec 21, 2017
fda2a2c
Add docs for PEP561 impl
emmatyping Dec 22, 2017
59f0c49
Add initial tests for PEP 561 checking
emmatyping Dec 22, 2017
c976008
Clean up tests a bit
emmatyping Dec 22, 2017
8df8b8d
Get tests passing
emmatyping Dec 22, 2017
4ca6939
Add note about tests
emmatyping Dec 22, 2017
a96601c
Clear site-packages from cache.
emmatyping Jan 3, 2018
336fb6b
Show sample package layout, change help text
emmatyping Jan 3, 2018
8492d8b
Merge branch 'master' into pep561-impl
emmatyping Jan 3, 2018
c41eef2
Merge branch 'master' into pep561-impl
emmatyping Jan 3, 2018
1f005d7
Fix deletion of site-packages from cache
emmatyping Feb 1, 2018
45afe58
Simplify testcase file creation/deletion
emmatyping Feb 1, 2018
e7f23bb
Don't use common path and fix lint errors
emmatyping Feb 1, 2018
d74eae8
Merge branch 'master' into pep561-impl
emmatyping Feb 14, 2018
5822884
Update PEP561 implementation, docs
emmatyping Feb 15, 2018
c734bc2
Clarify python-executable purpose
emmatyping Feb 15, 2018
1d7cc7e
Document --python-executable
emmatyping Feb 15, 2018
1ac4253
Assure dir cache is always set for a key
emmatyping Feb 15, 2018
f681bf9
Fix indentation of code and command line
emmatyping Feb 15, 2018
85f233c
Fix silly indentation mistake (again)
emmatyping Feb 16, 2018
3726f18
Add check for Python packages if executable given
emmatyping Feb 16, 2018
59a2004
Finish implementation and tests for alternate executable
emmatyping Feb 16, 2018
77b3b66
Add note about advanced import methods
emmatyping Feb 16, 2018
1da6e58
Remove undocumented flag
emmatyping Feb 16, 2018
e54025f
Maintain source information in traceback
emmatyping Feb 16, 2018
056dc8f
Clean up testpackages docstrings
emmatyping Feb 16, 2018
297fac6
Even better tracebacks for package tests
emmatyping Feb 16, 2018
e35e7aa
User install on Python not executing tests
emmatyping Feb 16, 2018
ecb702e
Better debug info on failed typecheck
emmatyping Feb 16, 2018
1a41262
Check if package was installed user
emmatyping Feb 16, 2018
31dab8d
Check if user site exits
emmatyping Feb 16, 2018
ff15057
Parentheses have haunted me since Scheme
emmatyping Feb 16, 2018
9442765
Don't unconditionally set python
emmatyping Feb 16, 2018
a34e7e8
Cleanup tests
emmatyping Feb 16, 2018
0fd592a
Fix for mypy check
emmatyping Feb 16, 2018
4cbe21a
Remove debugging info
emmatyping Feb 16, 2018
f566ed0
Try to delete simple.py after all tests in case have run
emmatyping Feb 16, 2018
206f70b
Make tearDownClass a classmethod
emmatyping Feb 16, 2018
2dbff97
Don't clean up twice, as it can break stubgen tests
emmatyping Feb 16, 2018
e33ceb7
Set python version from executable
emmatyping Feb 16, 2018
644e9a5
Fix mypy self check and doc indentation
emmatyping Feb 16, 2018
af38a12
Dedent docs
emmatyping Feb 18, 2018
b7f0788
Add missed flag back
emmatyping Feb 18, 2018
0564a5c
Remove silencing of errors in installed packages
emmatyping Feb 20, 2018
d17582b
Clean up get_package_dirs
emmatyping Feb 20, 2018
085d002
Make assert a user facing error
emmatyping Feb 21, 2018
8958dc7
Refactor get_package_dirs
emmatyping Feb 21, 2018
84fd527
Make test package typesafe to avoid error
emmatyping Feb 21, 2018
4c0ff1b
Clarify docs of unsupported import features
emmatyping Feb 21, 2018
a917ff5
Reverse equality order
emmatyping Feb 21, 2018
83ab973
Correct to more sensible key type for package_dir_cache
emmatyping Feb 21, 2018
cfac326
python -> python_executable
emmatyping Feb 21, 2018
aefcb96
Set python_executable based on python_version
emmatyping Feb 21, 2018
380e301
Fix weird indentation
emmatyping Feb 21, 2018
47d8e0d
Refactor and clarify checks for package information
emmatyping Feb 21, 2018
5c19e8c
Simplify check
emmatyping Feb 21, 2018
56dfcd4
Last python -> python_executable
emmatyping Feb 21, 2018
4293dad
Use lru_cache on get_package_dirs
emmatyping Feb 21, 2018
b810d3e
Fix lint
emmatyping Feb 21, 2018
17488ad
Refactor version setting from executable
emmatyping Feb 21, 2018
e348471
Handle python executable with spaces
emmatyping Feb 21, 2018
8184937
Return early in get_package_dirs
emmatyping Feb 21, 2018
97f29cc
Refactor and clean up testpackages
emmatyping Feb 21, 2018
928683a
Fix executable flag and version inference
emmatyping Feb 21, 2018
ae65564
Clean up Python version/executable inference
emmatyping Feb 21, 2018
f6c4327
Make typedpkg python2 compatible
emmatyping Feb 21, 2018
d475d4b
Overwrite default Python version if python_executable set
emmatyping Feb 21, 2018
03cd378
Move returns into try blocks
emmatyping Feb 21, 2018
3a8ca60
Refactor python-version/executable inference
emmatyping Feb 22, 2018
e1f9494
Clarify searching for packages and mixed packages
emmatyping Feb 22, 2018
b5cbd09
Clarify default behaviour of python-executable flag
emmatyping Feb 22, 2018
fc58e4c
Comment and refactor getsitepackage usage
emmatyping Feb 22, 2018
96e2f55
Make python_executable mandatory for find_packages
emmatyping Feb 23, 2018
80f4a35
Remove py.typed file from -stubs test package
emmatyping Feb 23, 2018
dc29e51
Write testpackages to test folder
emmatyping Feb 23, 2018
be733c5
Refactor tests to not be run with package check
emmatyping Feb 23, 2018
c1264a0
Disable pep561 searching with --no-site-packages
emmatyping Feb 24, 2018
ceacbff
Fix return type to be non-optional
emmatyping Feb 24, 2018
f389f64
Set python_executable to None if not inferred
emmatyping Feb 24, 2018
1bd9f66
Set flags for tests needing 3.6
emmatyping Feb 24, 2018
806fbef
Document no-site-packages
emmatyping Feb 24, 2018
c9e3361
Fix bugs with running mypy on 3.4
emmatyping Feb 24, 2018
7be3555
Merge branch 'master' of https://github.com/python/mypy into pep561-impl
emmatyping Feb 24, 2018
5fc9d52
Disable PEP561 searching if --no-site-packages is passed
emmatyping Feb 25, 2018
ae86abd
Clean up tests
emmatyping Feb 26, 2018
0bf024f
Move no-site-packages to special-opts
emmatyping Feb 26, 2018
c9c35c1
Remove duplicate exit and error message
emmatyping Feb 26, 2018
dca9c54
Refactor name, add missing paren
emmatyping Feb 26, 2018
a929b46
Fix test import
emmatyping Feb 26, 2018
e56ffe3
Fix silly name mistake
emmatyping Feb 26, 2018
72d7b0a
Link to PEP 561 and add note about inference
emmatyping Feb 26, 2018
c9f6bc2
Fixup docs
emmatyping Feb 26, 2018
4698d23
Refactor find_module and clarify comment
emmatyping Mar 1, 2018
db0680a
Refactor find_module to not be monolithic
emmatyping Mar 5, 2018
8367e57
Key find_module_dir_cache with lib_path as well
emmatyping Mar 5, 2018
24b6742
Don't mutate dir cache with site packages
emmatyping Mar 5, 2018
afb80ea
Refactor stub package searching
emmatyping Mar 5, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Set flags for tests needing 3.6
  • Loading branch information
emmatyping committed Feb 24, 2018
commit 1bd9f6604a1ca04ccd8519a4cabfdc76f0572c63
1 change: 1 addition & 0 deletions mypy/test/testcmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def test_python_cmdline(testcase: DataDrivenTestCase) -> None:
file.write('{}\n'.format(s))
args = parse_args(testcase.input[0])
args.append('--show-traceback')
args.append('--no-site-packages')
# Type check the program.
fixed = [python3_path,
os.path.join(testcase.old_cwd, 'scripts', 'mypy')]
Expand Down
2 changes: 2 additions & 0 deletions mypy/test/testdiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def build(self, source: str) -> Tuple[List[str], Optional[Dict[str, MypyFile]]]:
options.use_builtins_fixtures = True
options.show_traceback = True
options.cache_dir = os.devnull
options.python_version = (3, 6)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems a bit arbitrary. Why not mypy.defaults.PYTHON3_VERSION? Or sys.version_info[:2]? (Then again I realize this is very far from your code -- the feature that this tests isn't even announced yet. :-)

Ditto for testmerge.py, and half-ditto for testsemanal.py.

options.no_site_packages = True
try:
result = build.build(sources=[BuildSource('main', None, source)],
options=options,
Expand Down
2 changes: 2 additions & 0 deletions mypy/test/testmerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def build(self, source: str) -> Tuple[List[str], Optional[BuildManager], Dict[st
options.fine_grained_incremental = True
options.use_builtins_fixtures = True
options.show_traceback = True
options.python_version = (3, 6)
options.no_site_packages = True
main_path = os.path.join(test_temp_dir, 'main')
with open(main_path, 'w') as f:
f.write(source)
Expand Down
3 changes: 2 additions & 1 deletion mypy/test/testpythoneval.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_python_evaluation(testcase: DataDrivenTestCase) -> None:
version.
"""
assert testcase.old_cwd is not None, "test was not properly set up"
mypy_cmdline = ['--show-traceback']
mypy_cmdline = ['--show-traceback', '--no-site-packages']
py2 = testcase.name.lower().endswith('python2')
if py2:
mypy_cmdline.append('--py2')
Expand All @@ -59,6 +59,7 @@ def test_python_evaluation(testcase: DataDrivenTestCase) -> None:
return
else:
interpreter = python3_path
mypy_cmdline.append('--python-version=3.6')

# Write the program to a file.
program = '_' + testcase.name + '.py'
Expand Down
2 changes: 2 additions & 0 deletions mypy/test/testsemanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def get_semanal_options() -> Options:
options.use_builtins_fixtures = True
options.semantic_analysis_only = True
options.show_traceback = True
options.python_version = (3, 6)
options.no_site_packages = True
return options


Expand Down
14 changes: 7 additions & 7 deletions test-data/unit/cmdline.test
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ m.py:6: error: Explicit "Any" is not allowed
m.py:9: error: Explicit "Any" is not allowed

[case testDisallowAnyExplicitVarDeclaration]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar for the Python version here. Maybe all these tests should be run with 3.6 unless they override it?


[file mypy.ini]
[[mypy]
Expand All @@ -601,7 +601,7 @@ m.py:3: error: Explicit "Any" is not allowed
m.py:5: error: Explicit "Any" is not allowed

[case testDisallowAnyExplicitGenericVarDeclaration]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py

[file mypy.ini]
[[mypy]
Expand Down Expand Up @@ -785,7 +785,7 @@ N = TypedDict('N', {'x': str, 'y': List}) # no error
m.py:4: error: Explicit "Any" is not allowed

[case testDisallowAnyGenericsTupleNoTypeParams]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
[file mypy.ini]
[[mypy]
[[mypy-m]
Expand Down Expand Up @@ -821,7 +821,7 @@ def g(s: List[Tuple[str, str]]) -> None: pass # no error
m.py:3: error: Missing type parameters for generic type

[case testDisallowAnyGenericsTypeType]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
[file mypy.ini]
[[mypy]
[[mypy-m]
Expand Down Expand Up @@ -858,7 +858,7 @@ def g(l: L[str]) -> None: pass # no error
m.py:5: error: Missing type parameters for generic type

[case testDisallowAnyGenericsGenericAlias]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
[file mypy.ini]
[[mypy]
[[mypy-m]
Expand All @@ -882,7 +882,7 @@ m.py:7: error: Missing type parameters for generic type
m.py:11: error: Missing type parameters for generic type

[case testDisallowAnyGenericsPlainList]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
[file mypy.ini]
[[mypy]
[[mypy-m]
Expand All @@ -906,7 +906,7 @@ m.py:8: error: Need type annotation for 'x'
m.py:9: error: Missing type parameters for generic type

[case testDisallowAnyGenericsCustomGenericClass]
# cmd: mypy m.py
# cmd: mypy --python-version=3.6 m.py
[file mypy.ini]
[[mypy]
[[mypy-m]
Expand Down
1 change: 1 addition & 0 deletions test-data/unit/diff.test
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ __main__.Point
__main__.p

[case testTypedDict2]
# flags: --python-version 3.6 --no-site-packages
from mypy_extensions import TypedDict
class Point(TypedDict):
x: int
Expand Down
2 changes: 1 addition & 1 deletion test-data/unit/reports.test
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ Total 0 16 100.00%


[case testAnyExpressionsReportTypesOfAny]
# cmd: mypy --any-exprs-report report n.py
# cmd: mypy --no-site-packages --python-version=3.6 --any-exprs-report report n.py

[file n.py]
from typing import Any, List
Expand Down