From 87dec24616b9fdac526df2443b403a0e9c94f3de Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Wed, 27 Nov 2019 19:43:02 +0000 Subject: [PATCH 1/4] Treat --pythov-version=X.Y and --python-version X.Y equally --- mypy/test/helpers.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py index 2a4b56d2230c..d125ab4745af 100644 --- a/mypy/test/helpers.py +++ b/mypy/test/helpers.py @@ -391,7 +391,8 @@ def parse_options(program_text: str, testcase: DataDrivenTestCase, # Allow custom python version to override testcase_pyversion if (not flag_list or - all(flag not in flag_list for flag in ['--python-version', '-2', '--py2'])): + all(flag.split('=')[0] not in ['--python-version', '-2', '--py2'] + for flag in flag_list)): options.python_version = testcase_pyversion(testcase.file, testcase.name) if testcase.config.getoption('--mypy-verbose'): From 65d275cd377c5771ef8bd187315927f6873a4741 Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Wed, 27 Nov 2019 19:49:17 +0000 Subject: [PATCH 2/4] Update a test --- test-data/unit/check-literal.test | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test-data/unit/check-literal.test b/test-data/unit/check-literal.test index 222619c0891d..058d6ce0751a 100644 --- a/test-data/unit/check-literal.test +++ b/test-data/unit/check-literal.test @@ -216,12 +216,12 @@ expr_com_3 = ... # type: Literal['3'] expr_com_4 = ... # type: Literal['True'] expr_com_5 = ... # type: Literal['None'] expr_com_6 = ... # type: Literal['"foo"'] -reveal_type(expr_com_1) # N: Revealed type is 'Literal['a+b']' -reveal_type(expr_com_2) # N: Revealed type is 'Literal['1+2']' -reveal_type(expr_com_3) # N: Revealed type is 'Literal['3']' -reveal_type(expr_com_4) # N: Revealed type is 'Literal['True']' -reveal_type(expr_com_5) # N: Revealed type is 'Literal['None']' -reveal_type(expr_com_6) # N: Revealed type is 'Literal['"foo"']' +reveal_type(expr_com_1) # N: Revealed type is 'Literal[u'a+b']' +reveal_type(expr_com_2) # N: Revealed type is 'Literal[u'1+2']' +reveal_type(expr_com_3) # N: Revealed type is 'Literal[u'3']' +reveal_type(expr_com_4) # N: Revealed type is 'Literal[u'True']' +reveal_type(expr_com_5) # N: Revealed type is 'Literal[u'None']' +reveal_type(expr_com_6) # N: Revealed type is 'Literal[u'"foo"']' [builtins fixtures/bool.pyi] [out] From 8967c1d52a07df7a0413af01dc6a48e97ffe6e8d Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Wed, 27 Nov 2019 19:56:53 +0000 Subject: [PATCH 3/4] Simplify code --- mypy/test/helpers.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py index d125ab4745af..bbfca12ad5e0 100644 --- a/mypy/test/helpers.py +++ b/mypy/test/helpers.py @@ -389,10 +389,8 @@ def parse_options(program_text: str, testcase: DataDrivenTestCase, options.strict_optional = False options.error_summary = False - # Allow custom python version to override testcase_pyversion - if (not flag_list or - all(flag.split('=')[0] not in ['--python-version', '-2', '--py2'] - for flag in flag_list)): + # Allow custom python version to override testcase_pyversion. + if all(flag.split('=')[0] not in ['--python-version', '-2', '--py2'] for flag in flag_list): options.python_version = testcase_pyversion(testcase.file, testcase.name) if testcase.config.getoption('--mypy-verbose'): From 5d19436aa2b6a03cd1d41f1768e5b313dda79cbe Mon Sep 17 00:00:00 2001 From: Ivan Levkivskyi Date: Wed, 27 Nov 2019 20:07:40 +0000 Subject: [PATCH 4/4] Fix self-check --- mypy/test/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mypy/test/helpers.py b/mypy/test/helpers.py index bbfca12ad5e0..6007a0a7f849 100644 --- a/mypy/test/helpers.py +++ b/mypy/test/helpers.py @@ -375,7 +375,6 @@ def parse_options(program_text: str, testcase: DataDrivenTestCase, if flags2: flags = flags2 - flag_list = None if flags: flag_list = flags.group(1).split() flag_list.append('--no-site-packages') # the tests shouldn't need an installed Python @@ -384,6 +383,7 @@ def parse_options(program_text: str, testcase: DataDrivenTestCase, # TODO: support specifying targets via the flags pragma raise RuntimeError('Specifying targets via the flags pragma is not supported.') else: + flag_list = [] options = Options() # TODO: Enable strict optional in test cases by default (requires *many* test case changes) options.strict_optional = False pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy