This repository was archived by the owner on Nov 3, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Expand file tree Collapse file tree 4 files changed +35
-5
lines changed Original file line number Diff line number Diff line change @@ -507,16 +507,28 @@ def parse_from_import_statement(self):
507
507
508
508
"""
509
509
log .debug ('parsing from/import statement.' )
510
+ is_future_import = self ._parse_from_import_source ()
511
+ self ._parse_from_import_names (is_future_import )
512
+
513
+ def _parse_from_import_source (self ):
514
+ """Parse the 'from x import' part in a 'from x import y' statement.
515
+
516
+ Return true iff `x` is __future__.
517
+ """
510
518
assert self .current .value == 'from' , self .current .value
511
519
self .stream .move ()
512
520
is_future_import = self .current .value == '__future__'
513
521
self .stream .move ()
514
522
while (self .current .kind in (tk .DOT , tk .NAME , tk .OP ) and
515
- self .current .value != 'import' ):
523
+ self .current .value != 'import' ):
516
524
self .stream .move ()
517
525
self .check_current (value = 'import' )
518
526
assert self .current .value == 'import' , self .current .value
519
527
self .stream .move ()
528
+ return is_future_import
529
+
530
+ def _parse_from_import_names (self , is_future_import ):
531
+ """Parse the 'y' part in a 'from x import y' statement."""
520
532
if self .current .value == '(' :
521
533
self .consume (tk .OP )
522
534
expected_end_kind = tk .OP
Original file line number Diff line number Diff line change 1
1
"""A valid module docstring."""
2
2
3
- from .all_import_aux import __all__ as not_dunder_all
3
+ from .all_import_aux import __all__
4
4
from .expected import Expectation
5
5
6
6
expectation = Expectation ()
7
7
expect = expectation .expect
8
8
9
- __all__ = ('public_func' , )
10
-
11
9
12
10
@expect ("D103: Missing docstring in public function" )
13
11
def public_func ():
14
12
pass
15
13
16
14
17
- def private_func ():
15
+ @expect ("D103: Missing docstring in public function" )
16
+ def this ():
18
17
pass
Original file line number Diff line number Diff line change
1
+ """A valid module docstring."""
2
+
3
+ from .all_import_aux import __all__ as not_dunder_all
4
+ from .expected import Expectation
5
+
6
+ expectation = Expectation ()
7
+ expect = expectation .expect
8
+
9
+ __all__ = ('public_func' , )
10
+
11
+
12
+ @expect ("D103: Missing docstring in public function" )
13
+ def public_func ():
14
+ pass
15
+
16
+
17
+ def private_func ():
18
+ pass
Original file line number Diff line number Diff line change @@ -261,6 +261,7 @@ def test_token_stream():
261
261
'comment_after_def_bug' ,
262
262
'multi_line_summary_start' ,
263
263
'all_import' ,
264
+ 'all_import_as' ,
264
265
])
265
266
def test_pep257 (test_case ):
266
267
"""Run domain-specific tests from test.py file."""
You can’t perform that action at this time.
0 commit comments