From dd659aa8870b5c0cf00cfe23c6511aa4ae619d0e Mon Sep 17 00:00:00 2001 From: Etienne Tripier Date: Wed, 26 Apr 2023 12:14:18 -0700 Subject: [PATCH] More tests --- .../long_strings_flag_disabled.py | 5 -- tests/data/preview/comments7.py | 62 +++++-------------- tests/data/preview/long_strings.py | 5 -- tests/data/preview/prefer_rhs_split.py | 16 ++--- tests/data/simple_cases/comments6.py | 26 ++++++++ 5 files changed, 50 insertions(+), 64 deletions(-) diff --git a/tests/data/miscellaneous/long_strings_flag_disabled.py b/tests/data/miscellaneous/long_strings_flag_disabled.py index 1fdadf7ac40..db3954e3abd 100644 --- a/tests/data/miscellaneous/long_strings_flag_disabled.py +++ b/tests/data/miscellaneous/long_strings_flag_disabled.py @@ -276,11 +276,6 @@ def foo(): x = f"This is a {{really}} long string that needs to be split without a doubt (i.e. most definitely). In short, this {string} that can't possibly be {{expected}} to fit all together on one line. In {fact} it may even take up three or more lines... like four or five... but probably just four." -long_unmergable_string_with_pragma = ( - "This is a really long string that can't be merged because it has a likely pragma at the end" # pyright: ignore[reportGeneralTypeIssues] - " of it." -) - long_unmergable_string_with_pragma = ( "This is a really long string that can't be merged because it has a likely pragma at the end" # type: ignore " of it." diff --git a/tests/data/preview/comments7.py b/tests/data/preview/comments7.py index 6ca84f35528..79ba0c0f2c7 100644 --- a/tests/data/preview/comments7.py +++ b/tests/data/preview/comments7.py @@ -1,35 +1,20 @@ -from .config import ( - Any, - Bool, - ConfigType, - ConfigTypeAttributes, - Int, - Path, - # String, - # resolve_to_config_type, - # DEFAULT_TYPE_ATTRIBUTES, +from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( + MyLovelyCompanyTeamProjectComponent, # NOT DRY +) +from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( + MyLovelyCompanyTeamProjectComponent as component, # DRY ) - -from .config import ( +from .config import ( # String,; resolve_to_config_type,; DEFAULT_TYPE_ATTRIBUTES,; and some comments, Any, Bool, ConfigType, ConfigTypeAttributes, Int, - no_comma_here_yet - # and some comments, - # resolve_to_config_type, - # DEFAULT_TYPE_ATTRIBUTES, -) -from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( - MyLovelyCompanyTeamProjectComponent # NOT DRY -) -from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( - MyLovelyCompanyTeamProjectComponent as component # DRY + Path, + no_comma_here_yet, ) - result = 1 # look ma, no comment migration xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx result = ( @@ -133,38 +118,23 @@ def test_fails_invalid_post_data( # output -from .config import ( - Any, - Bool, - ConfigType, - ConfigTypeAttributes, - Int, - Path, - # String, - # resolve_to_config_type, - # DEFAULT_TYPE_ATTRIBUTES, +from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( + MyLovelyCompanyTeamProjectComponent, # NOT DRY +) +from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( + MyLovelyCompanyTeamProjectComponent as component, # DRY ) - -from .config import ( +from .config import ( # String,; resolve_to_config_type,; DEFAULT_TYPE_ATTRIBUTES,; and some comments, Any, Bool, ConfigType, ConfigTypeAttributes, Int, + Path, no_comma_here_yet, - # and some comments, - # resolve_to_config_type, - # DEFAULT_TYPE_ATTRIBUTES, -) -from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( - MyLovelyCompanyTeamProjectComponent, # NOT DRY -) -from com.my_lovely_company.my_lovely_team.my_lovely_project.my_lovely_component import ( - MyLovelyCompanyTeamProjectComponent as component, # DRY ) - result = 1 # look ma, no comment migration xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx result = 1 # look ma, no comment migration xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx @@ -187,8 +157,8 @@ def func(): 0.0789, a[-1], # type: ignore ) - c = call(0.0123, 0.0456, 0.0789, 0.0123, 0.0789, a[-1]) # type: ignore c = call(0.0123, 0.0456, 0.0789, 0.0123, 0.0789, a[-1]) # pyright: ignore[reportGeneralTypeIssues] + c = call(0.0123, 0.0456, 0.0789, 0.0123, 0.0789, a[-1]) # type: ignore c = call( 0.0123, 0.0456, diff --git a/tests/data/preview/long_strings.py b/tests/data/preview/long_strings.py index d84c622c1ff..c68da3a8632 100644 --- a/tests/data/preview/long_strings.py +++ b/tests/data/preview/long_strings.py @@ -231,11 +231,6 @@ def foo(): x = f"This is a {{really}} long string that needs to be split without a doubt (i.e. most definitely). In short, this {string} that can't possibly be {{expected}} to fit all together on one line. In {fact} it may even take up three or more lines... like four or five... but probably just four." -long_unmergable_string_with_pragma = ( - "This is a really long string that can't be merged because it has a likely pragma at the end" # pyright: ignore[reportGeneralTypeIssues] - " of it." -) - long_unmergable_string_with_pragma = ( "This is a really long string that can't be merged because it has a likely pragma at the end" # type: ignore " of it." diff --git a/tests/data/preview/prefer_rhs_split.py b/tests/data/preview/prefer_rhs_split.py index b54434f91e6..f518a6ecb33 100644 --- a/tests/data/preview/prefer_rhs_split.py +++ b/tests/data/preview/prefer_rhs_split.py @@ -55,31 +55,31 @@ ) -# Make sure unsplittable type ignore won't be moved. -some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 +# Make sure unsplittable pyright: ignore comments won't be moved. +some_kind_of_table[some_key] = util.some_function( # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 some_arg ).intersection(pk_cols) some_kind_of_table[ some_key -] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 +] = lambda obj: obj.some_long_named_method() # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 some_kind_of_table[ - some_key # type: ignore # noqa: E501 + some_key # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 ] = lambda obj: obj.some_long_named_method() -# Make sure unsplittable pyright: ignore comments won't be moved. -some_kind_of_table[some_key] = util.some_function( # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 +# Make sure unsplittable type ignore won't be moved. +some_kind_of_table[some_key] = util.some_function( # type: ignore # noqa: E501 some_arg ).intersection(pk_cols) some_kind_of_table[ some_key -] = lambda obj: obj.some_long_named_method() # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 +] = lambda obj: obj.some_long_named_method() # type: ignore # noqa: E501 some_kind_of_table[ - some_key # pyright: ignore[reportGeneralTypeIssues] # noqa: E501 + some_key # type: ignore # noqa: E501 ] = lambda obj: obj.some_long_named_method() diff --git a/tests/data/simple_cases/comments6.py b/tests/data/simple_cases/comments6.py index 735c6aa6d7a..f493243f397 100644 --- a/tests/data/simple_cases/comments6.py +++ b/tests/data/simple_cases/comments6.py @@ -86,6 +86,19 @@ def f( def func( a=some_list[0], # type: int ): # type: () -> int + c = call( + 0.0123, + 0.0456, + 0.0789, + 0.0123, + 0.0456, + 0.0789, + 0.0123, + 0.0456, + 0.0789, + a[-1], # pyright: ignore[reportGeneralTypeIssues] + ) + c = call( 0.0123, 0.0456, @@ -99,6 +112,10 @@ def func( a[-1], # type: ignore ) + c = call( + "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # pyright: ignore[reportGeneralTypeIssues] + ) + c = call( "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa", "aaaaaaaa" # type: ignore ) @@ -108,11 +125,20 @@ def func( "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" ) +AAAAAAAAAAAAA = [AAAAAAAAAAAAA] + SHARED_AAAAAAAAAAAAA + USER_AAAAAAAAAAAAA + AAAAAAAAAAAAA # pyright: ignore[reportGeneralTypeIssues] + AAAAAAAAAAAAA = [AAAAAAAAAAAAA] + SHARED_AAAAAAAAAAAAA + USER_AAAAAAAAAAAAA + AAAAAAAAAAAAA # type: ignore +call_to_some_function_asdf( + foo, + [AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # pyright: ignore[reportGeneralTypeIssues] +) + call_to_some_function_asdf( foo, [AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, AAAAAAAAAAAAAAAAAAAAAAA, BBBBBBBBBBBB], # type: ignore ) +aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*items))) # pyright: ignore[reportGeneralTypeIssues] + aaaaaaaaaaaaa, bbbbbbbbb = map(list, map(itertools.chain.from_iterable, zip(*items))) # type: ignore[arg-type]