diff --git a/mypy/fastparse.py b/mypy/fastparse.py index 8b6eb3d28b67..f68d1b0279d0 100644 --- a/mypy/fastparse.py +++ b/mypy/fastparse.py @@ -736,7 +736,7 @@ def is_star2arg(k: ast35.keyword) -> bool: # Num(object n) -- a number as a PyObject. @with_line def visit_Num(self, n: ast35.Num) -> Union[IntExpr, FloatExpr, ComplexExpr]: - if getattr(n, 'underscores', None) and self.pyversion < (3, 6): + if getattr(n, 'contains_underscores', None) and self.pyversion < (3, 6): raise FastParserError('Underscores in numeric literals are only ' 'supported in Python 3.6', n.lineno, n.col_offset) if isinstance(n.n, int): diff --git a/mypy/test/testcheck.py b/mypy/test/testcheck.py index b795bd5dcfaf..8cbca4262d17 100644 --- a/mypy/test/testcheck.py +++ b/mypy/test/testcheck.py @@ -74,7 +74,7 @@ if 'annotation' in typed_ast.ast35.Assign._fields: files.append('check-newsyntax.test') -if 'underscores' in typed_ast.ast35.Num._fields: +if 'contains_underscores' in typed_ast.ast35.Num._fields: files.append('check-underscores.test') diff --git a/test-data/unit/check-underscores.test b/test-data/unit/check-underscores.test index 51926c3adf1e..a1d88cbf268f 100644 --- a/test-data/unit/check-underscores.test +++ b/test-data/unit/check-underscores.test @@ -12,4 +12,5 @@ x = 1000_000_ # E: invalid token # flags: --fast-parser --python-version 3.6 x: int x = 1000_000 +x = 0x_FF_FF_FF_FF y: str = 1000_000.000_001 # E: Incompatible types in assignment (expression has type "float", variable has type "str")