-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix double quotes in Literal type hint (#123)
- Loading branch information
Showing
9 changed files
with
163 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
tests/data/edge_cases/09_double_quotes_in_Literal/google.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# fmt: off | ||
|
||
# This edge case comes from https://github.com/jsh9/pydoclint/issues/105 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Literal | ||
|
||
|
||
def func_1(arg1: Literal["foo"]) -> Literal["foo"]: | ||
""" | ||
Test literal. | ||
Args: | ||
arg1 (Literal["foo"]): Arg 1 | ||
Returns: | ||
Literal["foo"]: The literal string "foo". | ||
""" | ||
return "foo" | ||
|
||
|
||
def func_2(arg1: Literal['foo']) -> Literal['foo']: | ||
""" | ||
Test literal. | ||
Args: | ||
arg1 (Literal['foo']): Arg 1 | ||
Returns: | ||
Literal['foo']: The literal string "foo". | ||
""" | ||
return "foo" | ||
|
||
|
||
def func_3(arg1: Literal['foo']) -> tuple[Literal['foo'], Literal["bar"]]: | ||
""" | ||
Test literal. | ||
Args: | ||
arg1 (Literal['foo']): Arg 1 | ||
Returns: | ||
tuple[Literal['foo'], Literal["bar"]]: The literal strings 'foo' & "bar" | ||
""" | ||
return 'foo', "bar" |
57 changes: 57 additions & 0 deletions
57
tests/data/edge_cases/09_double_quotes_in_Literal/numpy.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# fmt: off | ||
|
||
# This edge case comes from https://github.com/jsh9/pydoclint/issues/105 | ||
|
||
from __future__ import annotations | ||
|
||
from typing import Literal | ||
|
||
|
||
def func_1(arg1: Literal["foo"]) -> Literal["foo"]: | ||
""" | ||
Test literal. | ||
Parameters | ||
---------- | ||
arg1 : Literal["foo"] | ||
Arg 1 | ||
Returns | ||
------- | ||
Literal["foo"] | ||
The literal string "foo". | ||
""" | ||
return "foo" | ||
|
||
|
||
def func_2(arg1: Literal['foo']) -> Literal['foo']: | ||
""" | ||
Test literal. | ||
Parameters | ||
---------- | ||
arg1 : Literal['foo'] | ||
Arg 1 | ||
Returns | ||
------- | ||
Literal['foo'] | ||
The literal string 'foo'. | ||
""" | ||
return "foo" | ||
|
||
|
||
def func_3() -> tuple[Literal['foo'], Literal["bar"]]: | ||
""" | ||
Test literal. | ||
Returns | ||
------- | ||
Literal['foo'] | ||
The literal string 'foo'. And the quote style (single) must match | ||
the function signature. | ||
Literal["bar"] | ||
The literal string "bar". And the quote style (double) must match | ||
the function signature. | ||
""" | ||
return "foo", 'bar' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters