mirror of
https://github.com/davidhalter/parso.git
synced 2026-10-08 13:05:13 +08:00
Add support for 'from __future__ import annotations'
PEP 563 brought a new `__future__` import for post-poning evaluation of annotations that introduced in 3.7. This patch adds support for that future feature, and removes 'all_feature_names' from that list since it is not valid a syntax (`from __future__ import all_feature_names`). Also it fixes a bug related usage of `ALLOWED_FUTURES` (global and version independant flags) instead of `allowed_futures` (extended version of the previ ous flag that has some version specific flags, probably unnoticed)
This commit is contained in:
1 parent
34b8b7dd79
commit
261132e74c
2 files changed
+10
-6
No files matched your search
@@ -13,8 +13,8 @@ _STAR_EXPR_PARENTS = ('testlist_star_expr', 'testlist_comp', 'exprlist')
|
||||
_MAX_BLOCK_SIZE = 20
|
||||
_MAX_INDENT_COUNT = 100
|
||||
ALLOWED_FUTURES = (
|
||||
'all_feature_names', 'nested_scopes', 'generators', 'division',
|
||||
'absolute_import', 'with_statement', 'print_function', 'unicode_literals',
|
||||
'nested_scopes', 'generators', 'division', 'absolute_import',
|
||||
'with_statement', 'print_function', 'unicode_literals',
|
||||
)
|
||||
_COMP_FOR_TYPES = ('comp_for', 'sync_comp_for')
|
||||
|
||||
@@ -622,13 +622,14 @@ class _FutureImportRule(SyntaxRule):
|
||||
allowed_futures = list(ALLOWED_FUTURES)
|
||||
if self._normalizer.version >= (3, 5):
|
||||
allowed_futures.append('generator_stop')
|
||||
|
||||
if self._normalizer.version >= (3, 7):
|
||||
allowed_futures.append('annotations')
|
||||
if name == 'braces':
|
||||
self.add_issue(node, message="not a chance")
|
||||
elif name == 'barry_as_FLUFL':
|
||||
m = "Seriously I'm not implementing this :) ~ Dave"
|
||||
self.add_issue(node, message=m)
|
||||
elif name not in ALLOWED_FUTURES:
|
||||
elif name not in allowed_futures:
|
||||
message = "future feature %s is not defined" % name
|
||||
self.add_issue(node, message=message)
|
||||
|
||||
|
||||
Reference in new issue
Block a user