This repository has been archived by the owner on Apr 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from tannewt/improve_types
Improve union type handling and support :data:
- Loading branch information
Showing
5 changed files
with
76 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
|
||
from rst2pyi.core import Converter | ||
from rst2pyi.types import Line, Lines | ||
|
||
from .core import ConverterTest |
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 @@ | ||
# Copyright 2019 John Reese | ||
# Licensed under the MIT license | ||
|
||
from unittest import TestCase | ||
|
||
from rst2pyi.core import Converter | ||
|
||
|
||
class ConverterTest(TestCase): | ||
def test_split_types(self): | ||
fn = Converter._split_types | ||
self.assertEqual(fn("Optional[int]"), {"Optional", "int"}) | ||
self.assertEqual(fn("Union[int, str]"), {"Union", "int", "str"}) | ||
self.assertEqual( | ||
fn("Optional[Union[int, str]]"), {"Optional", "Union", "int", "str"} | ||
) | ||
|
||
def test_convert_types(self): | ||
fn = Converter._convert_type | ||
self.assertEqual(fn("int or None"), "Optional[int]") | ||
self.assertEqual(fn("int or str"), "Union[int, str]") |
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