-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jos Verlinde <Jos.Verlinde@microsoft.com>
- Loading branch information
Showing
4 changed files
with
64 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#fmt: off | ||
""" | ||
add typealias | ||
""" | ||
|
||
|
||
def const(): ... | ||
|
||
|
||
def bar(): ... |
21 changes: 21 additions & 0 deletions
21
tests/codemods/codemod_test_cases/typealias_add/doc_stub.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,21 @@ | ||
# fmt: off | ||
""" | ||
add typealias | ||
""" | ||
|
||
|
||
from typing import TypeAlias | ||
|
||
UUID: TypeAlias = str | ||
_Flag: TypeAlias = int | ||
_Descriptor: TypeAlias = tuple["UUID", _Flag] | ||
_Characteristic: TypeAlias = (tuple["UUID", _Flag] | tuple["UUID", _Flag, tuple[_Descriptor, ...]]) | ||
_Service: TypeAlias = tuple["UUID", tuple[_Characteristic, ...]] | ||
x = 2 | ||
|
||
def bar(f:_Flag , d:_Descriptor ) -> _Service: | ||
""" | ||
Used to declare that the expression is a constant so that the compiler can | ||
optimise it. The use of this function should be as follows:: | ||
""" | ||
... |
22 changes: 22 additions & 0 deletions
22
tests/codemods/codemod_test_cases/typealias_add/expected.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,22 @@ | ||
# fmt: off | ||
""" | ||
add typealias | ||
""" | ||
from typing import TypeAlias | ||
|
||
UUID: TypeAlias = str | ||
_Flag: TypeAlias = int | ||
_Descriptor: TypeAlias = tuple["UUID", _Flag] | ||
_Characteristic: TypeAlias = (tuple["UUID", _Flag] | tuple["UUID", _Flag, tuple[_Descriptor, ...]]) | ||
_Service: TypeAlias = tuple["UUID", tuple[_Characteristic, ...]] | ||
|
||
|
||
def const(): ... | ||
|
||
|
||
def bar(f:_Flag , d:_Descriptor ) -> _Service: | ||
""" | ||
Used to declare that the expression is a constant so that the compiler can | ||
optimise it. The use of this function should be as follows:: | ||
""" | ||
... |