Skip to content
Snippets Groups Projects
Commit 512369c6 authored by Anthony Sottile's avatar Anthony Sottile
Browse files

Support annotated assignments (py36+)

parent 80359f56
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -105,6 +105,11 @@ async def foobar(a, b, c):
pass
"""
 
annotated_assign = """\
def f():
x: Any = None
"""
 
def get_complexity_number(snippet, strio, max=0):
"""Get the complexity number from the printed string."""
Loading
Loading
@@ -196,6 +201,14 @@ class McCabeTestCase(unittest.TestCase):
complexity = get_complexity_number(async_keywords, self.strio)
self.assertEqual(complexity, 3)
 
@pytest.mark.skipif(
sys.version_info < (3, 6),
reason="Annotated assignments are only valid on Python 3.6+",
)
def test_annotated_assignment(self):
complexity = get_complexity_number(annotated_assign, self.strio)
self.assertEqual(complexity, 1)
 
class RegressionTests(unittest.TestCase):
def setUp(self):
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment