Skip to content

Commit

Permalink
Update additional functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobtylerwalls committed Jul 7, 2024
1 parent 8492003 commit 2811003
Show file tree
Hide file tree
Showing 17 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions tests/functional/ext/private_import/private_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def c2_func() -> _TypeContainerC.C:
# This is allowed since all the imports are used for typing
from _TypeContainerExtra import TypeExtraA, TypeExtraB
from MakerContainerExtra import GetA, GetB
extraA: TypeExtraA = GetA()
extraB: TypeExtraB = GetB()
extra_a: TypeExtraA = GetA()
extra_b: TypeExtraB = GetB()

# This is not allowed because there is an import not used for typing
from _TypeContainerExtra2 import TypeExtra2, NotTypeExtra # [import-private-name]
Expand Down
1 change: 1 addition & 0 deletions tests/functional/ext/private_import/private_import.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[MAIN]
load-plugins=pylint.extensions.private_import,
const-naming-style=snake_case
2 changes: 1 addition & 1 deletion tests/functional/f/function_redefined.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def callback2():
return 24
return callback1(), callback2()

do_something: Callable[[], int]
do_something: Callable[[], int] # pylint: disable=invalid-name

def do_something() -> int:
return 1
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class CustomImplementation(CustomAbstractCls2): # [abstract-method,abstract-met
# Type annotations
var_tuple: tuple[int, int]
var_dict: dict[int, str]
var_orderedDict: collections.OrderedDict[int, str]
var_ordereddict: collections.OrderedDict[int, str]
var_container: collections.abc.Container[int]
var_sequence: collections.abc.Sequence[int]
var_iterable: collections.abc.Iterable[int]
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/g/generic_alias/generic_alias_collections.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[testoptions]
min_pyver=3.9

[MAIN]
const-naming-style=snake_case
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[testoptions]
max_pyver=3.9

[MAIN]
const-naming-style=snake_case
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[testoptions]
max_pyver=3.9

[MAIN]
const-naming-style=snake_case
4 changes: 2 additions & 2 deletions tests/functional/g/generic_alias/generic_alias_mixed_py39.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
import typing

# Type annotations
var_orderedDict: collections.OrderedDict[int, str]
var_ordered_dict: collections.OrderedDict[int, str]
var_container: collections.abc.Container[int]
var_sequence: collections.abc.Sequence[int]
var_iterable: collections.abc.Iterable[int]
var_awaitable: collections.abc.Awaitable[int]
var_pattern: re.Pattern[int]
var_bytestring: collections.abc.ByteString
var_hashable: collections.abc.Hashable
var_ContextManager: contextlib.AbstractContextManager[int]
var_context_manager: contextlib.AbstractContextManager[int]


# No implementation required for 'builtins'
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/g/generic_alias/generic_alias_mixed_py39.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[testoptions]
min_pyver=3.9

[MAIN]
const-naming-style=snake_case
2 changes: 1 addition & 1 deletion tests/functional/r/regression_02/regression_3979.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
else:
BasePathLike = os.PathLike

Foo: Union[str, BasePathLike] = "bar"
SOME_VAR: Union[str, BasePathLike] = "bar"
4 changes: 2 additions & 2 deletions tests/functional/t/type/typealias_naming_style_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

# Regression tests
# They are not TypeAlias, and thus shouldn't flag the message
x: Union[str, int] = 42
y: Union[str, int]
X: Union[str, int] = 42
Y: Union[str, int]
# But the following, using a good TypeAlias name, is:
GoodTypeAliasToUnion: TypeAlias = Union[str, int]

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/u/unsubscriptable_value_py37.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def __class_getitem__(cls, params):
Subscriptable[0]
Subscriptable()[0] # [unsubscriptable-object]

a: typing.List[int]
A: typing.List[int]
2 changes: 1 addition & 1 deletion tests/functional/u/unused/unused_import_py39.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
import typing as t


example: t.Annotated[str, "Path"] = "/foo/bar"
EXAMPLE: t.Annotated[str, "Path"] = "/foo/bar"
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import NoReturn, Set

# unused-import shouldn't be emitted for Path
example1: Set["Path"] = set()
EXAMPLE1: Set["Path"] = set()

def example2(_: "ArgumentParser") -> "NoReturn":
"""unused-import shouldn't be emitted for ArgumentParser or NoReturn."""
Expand All @@ -22,9 +22,9 @@ def example4(_: "PathLike[str]") -> None:
"""unused-import shouldn't be emitted for PathLike."""

# pylint shouldn't crash with the following strings in a type annotation context
example5: Set[""]
example6: Set[" "]
example7: Set["?"]
EXAMPLE5: Set[""]
EXAMPLE6: Set[" "]
EXAMPLE7: Set["?"]

class Class:
"""unused-import shouldn't be emitted for Namespace"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from typing import Literal as Lit

# str inside Literal shouldn't be treated as names
example1: t.Literal["ArgumentParser", Lit["Namespace", "ArgumentParser"]]
EXAMPLE1: t.Literal["ArgumentParser", Lit["Namespace", "ArgumentParser"]]


def unused_variable_example():
Expand All @@ -19,9 +19,9 @@ def unused_variable_example():


# pylint shouldn't crash with the following strings in a type annotation context
example3: Lit["", " ", "?"] = "?"
EXAMPLE3: Lit["", " ", "?"] = "?"


# See https://peps.python.org/pep-0586/#literals-enums-and-forward-references
example4: t.Literal["http.HTTPStatus.OK", "http.HTTPStatus.NOT_FOUND"]
example5: "t.Literal[HTTPStatus.OK, HTTPStatus.NOT_FOUND]"
EXAMPLE4: t.Literal["http.HTTPStatus.OK", "http.HTTPStatus.NOT_FOUND"]
EXAMPLE5: "t.Literal[HTTPStatus.OK, HTTPStatus.NOT_FOUND]"
4 changes: 2 additions & 2 deletions tests/input/func_noerror_cycle/a.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# pylint: disable=missing-docstring
from typing import List

from .b import var
from .b import VAR

LstT = List[int]

print(var)
print(VAR)
2 changes: 1 addition & 1 deletion tests/input/func_noerror_cycle/b.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
if TYPE_CHECKING:
from .a import LstT

var: "LstT" = [1, 2]
VAR: "LstT" = [1, 2]

0 comments on commit 2811003

Please sign in to comment.