Skip to content

Commit

Permalink
More tests
Browse files Browse the repository at this point in the history
  • Loading branch information
etripier committed Apr 26, 2023
1 parent 5eed5b5 commit dd659aa
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 64 deletions.
5 changes: 0 additions & 5 deletions tests/data/miscellaneous/long_strings_flag_disabled.py
Expand Up @@ -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."
Expand Down
62 changes: 16 additions & 46 deletions 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 = (
Expand Down Expand Up @@ -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
Expand All @@ -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,
Expand Down
5 changes: 0 additions & 5 deletions tests/data/preview/long_strings.py
Expand Up @@ -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."
Expand Down
16 changes: 8 additions & 8 deletions tests/data/preview/prefer_rhs_split.py
Expand Up @@ -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()


Expand Down
26 changes: 26 additions & 0 deletions tests/data/simple_cases/comments6.py
Expand Up @@ -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,
Expand All @@ -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
)
Expand All @@ -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]

0 comments on commit dd659aa

Please sign in to comment.