-
-
Notifications
You must be signed in to change notification settings - Fork 348
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
Simplify imports #594
Merged
Merged
Simplify imports #594
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
988fcf7
Changed import of reexport to explicit and bumped version
jmfrank63 a922db6
Replaced all import * with explicit imports and moved global update i…
jmfrank63 a9398a3
Formatting with yapf applied.\nVersion reverted to orig version 0.5.0…
jmfrank63 0651a6b
Added tests for pylint and jedi
jmfrank63 e668514
Fixed formatting
jmfrank63 0e1bf15
Added pylint and jedit to test-requirements.txt for tests
jmfrank63 6a42ded
Fixed path to be POSIX and Windows path
jmfrank63 e87a040
Replaced trio/__init__.py with trio.__file__
jmfrank63 a340b90
Module names for _core and _run are currently broken
jmfrank63 7421d65
replaced __all__ with namespace iteration and added pylint and jedi test
jmfrank63 d8cfb8e
merged with 0.6.0 rebase
jmfrank63 ca57e08
rebase continuation
jmfrank63 b99ac7e
Fix formating with yapf
jmfrank63 f95aeea
Removed _top_level_imports.py
jmfrank63 1ec2c0a
Reformatted with new yapf version 0.22 and skipped yedi test for 3.8-dev
jmfrank63 d8e2ac9
Fixed format in test_exports.py
jmfrank63 5bd0390
Fixed mising import of pytest in test_exports.py
jmfrank63 dde4d28
Changed reson message for jedi test being skipped
jmfrank63 0bd82f7
Moved to exception handling instead of pytest decorator for skipping …
jmfrank63 dad3880
changed TLD of readthedocs from org to io
jmfrank63 f13dd09
Addressed temporary issue with __all__ being still present in _core b…
jmfrank63 b3e4ff7
more changes accepted
jmfrank63 90ae080
Changed import of reexport to explicit and bumped version
jmfrank63 a3cb3a4
Formatting with yapf applied.\nVersion reverted to orig version 0.5.0…
jmfrank63 5c6f1b3
Added tests for pylint and jedi
jmfrank63 a90563c
Fixed path to be POSIX and Windows path
jmfrank63 057ed5b
Module names for _core and _run are currently broken
jmfrank63 61c05ce
replaced __all__ with namespace iteration and added pylint and jedi test
jmfrank63 19ff27e
rebasing
jmfrank63 cb05c86
Changed import of reexport to explicit and bumped version
jmfrank63 54f07de
rebase continuation
jmfrank63 933cdd0
Added tests for pylint and jedi
jmfrank63 026c380
Fixed formatting
jmfrank63 a38c381
Fixed path to be POSIX and Windows path
jmfrank63 f39acef
replaced __all__ with namespace iteration and added pylint and jedi test
jmfrank63 74fe457
Fix formating with yapf
jmfrank63 b97217d
Reformatted with new yapf version 0.22 and skipped yedi test for 3.8-dev
jmfrank63 e10619f
Fixed format in test_exports.py
jmfrank63 78dc15d
Addressed temporary issue with __all__ being still present in _core b…
jmfrank63 be19351
Rebase formatting
jmfrank63 5ad48b2
Fixed formatting after rebase
jmfrank63 e7d2fe0
Readded trio/_toplevel_core_reexports.py
jmfrank63 5fc025b
Synced .gitignore
jmfrank63 d569f5e
removed again TaskLocal from trio/__init__.py
jmfrank63 79e177e
reverted docs changes, removed TESTING variable and removed explicit …
jmfrank63 fe82149
Changed jedi completion test script to be an explicit script
jmfrank63 1520424
added open_signal_receiver to trio/__init__.py and _toplevel_core_ree…
jmfrank63 04106c0
Fixed formatting of trio/_toplevel_core_reexports.py
jmfrank63 fcc808d
Merge branch 'master' into simplify_imports
jmfrank63 3afdb8b
Added extra space after curly brace to check what happens about yapf …
jmfrank63 b492ebb
Deleted trio/_toplevel_core_reexports.py
jmfrank63 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 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 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 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 was deleted.
Oops, something went wrong.
This file contains 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 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 |
---|---|---|
@@ -1,20 +1,50 @@ | ||
import trio | ||
import trio.testing | ||
|
||
import jedi | ||
import os | ||
import pytest | ||
import sys | ||
|
||
from pylint.lint import PyLinter | ||
|
||
from .. import _core | ||
|
||
|
||
def test_core_is_properly_reexported(): | ||
# Each export from _core should be re-exported by exactly one of these | ||
# three modules: | ||
sources = [trio, trio.hazmat, trio.testing] | ||
for symbol in _core.__all__: | ||
for symbol in dir(_core): | ||
if symbol.startswith('_') or symbol == 'tests': | ||
continue | ||
found = 0 | ||
for source in sources: | ||
if ( | ||
symbol in source.__all__ | ||
symbol in dir(source) | ||
and getattr(source, symbol) is getattr(_core, symbol) | ||
): | ||
found += 1 | ||
print(symbol, found) | ||
assert found == 1 | ||
|
||
|
||
def test_pylint_sees_all_non_underscore_symbols_in_namespace(): | ||
# Test pylints ast to contain the same content as dir(trio) | ||
linter = PyLinter() | ||
ast_set = set(linter.get_ast(trio.__file__, 'trio')) | ||
trio_set = set([symbol for symbol in dir(trio) if symbol[0] != '_']) | ||
trio_set.remove('tests') | ||
assert trio_set - ast_set == set([]) | ||
|
||
|
||
def test_jedi_sees_all_completions(): | ||
# Test the jedi completion library get all in dir(trio) | ||
try: | ||
script = jedi.Script("import trio; trio.") | ||
completions = script.completions() | ||
trio_set = set([symbol for symbol in dir(trio) if symbol[:2] != '__']) | ||
jedi_set = set([cmp.name for cmp in completions]) | ||
assert trio_set - jedi_set == set([]) | ||
except NotImplementedError: | ||
pytest.skip("jedi does not yet support {}".format(sys.version)) |
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.
Probably worthwhile to factor out some of the namespace cleanup code from the two functions – I think in both cases we want to test something like: "the two sets are equivalent, if you ignore names that
.startswith("_")
,"tests"
, and"testing"
"?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.
Ok, I'll work myself through all the comments. Will take some time as this is all new stuff.
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.
No worries, take your time, and don't be afraid to ask for help if you get stuck :-)