-
Notifications
You must be signed in to change notification settings - Fork 0
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 #21 from VDBWRAIR/types
Type annotations for consensus.py
- Loading branch information
Showing
17 changed files
with
305 additions
and
53 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,5 @@ | ||
from Bio.SeqRecord import SeqRecord | ||
from typing import Generator, Any, Iterator | ||
|
||
def parse(*anything): # type: (*Any) -> Iterator[SeqRecord] | ||
pass |
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,6 @@ | ||
# from Bio.SeqIO import SeqIO | ||
from typing import NamedTuple | ||
class Stringable(object): | ||
def __str__(self): # type: () -> str | ||
pass | ||
SeqRecord = NamedTuple('SeqRecord', [('id', str), ('seq', Stringable)]) |
Empty file.
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,6 @@ | ||
1. Install [mypy](https://github.com/python/mypy#quick-start) | ||
|
||
2. Run mypy: `MYPYPATH=$PWD/mypy:$PWD/mypy/out mypy --py2 bioframework/consensus.py` | ||
|
||
If needed, uses `stubgen` to generate more stub files for other libraries. | ||
|
Empty file.
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,44 @@ | ||
from typing import List, Dict, Generator, Iterator, Iterable, Tuple | ||
from Bio import SeqIO | ||
from itertools import imap | ||
from Bio.SeqRecord import SeqRecord | ||
def test_long(): # type: () -> int | ||
return 11999999L | ||
def test_seqIO_map_fails(s): # type: (str) -> List[SeqRecord] | ||
return map(lambda x: x.id, SeqIO.parse(s)) | ||
|
||
#def test_seqIO_map_fails2(s): # type: (str) -> Iterator[SeqRecord] | ||
# return map(lambda x: x.id, SeqIO.parse(s)) | ||
def test_seqIO_map_passes(s): # type: (str) -> Iterable[str] | ||
return imap(lambda x: x.id, SeqIO.parse(s)) | ||
|
||
def test_seqIO(s): # type: (str) -> Iterator[SeqRecord] | ||
return SeqIO.parse(s) | ||
def test_list_seqIO(s): # type: (str) -> List[SeqRecord] | ||
return list(SeqIO.parse(s)) | ||
def test_seqIO_fails(s): # type: (str) -> List[str] | ||
return SeqIO.parse(s) | ||
def test_should_pass(s): # type: (SeqRecord) -> str | ||
return s.id | ||
def test_should_fail(s): # type: (SeqRecord) -> int | ||
return s.id | ||
#def test_should_fail(): # type: () -> List[SeqRecord] | ||
# return 3 | ||
|
||
#a = test_should_fail() | ||
def test_ordered_dict(od): # type: (Dict[str,int]) -> Dict[str,int] | ||
return 1 #type error 1 | ||
# | ||
#a = test_ordered_dict(1) #type error 2 | ||
# | ||
#def test_me(): | ||
# a = test_ordered_dict(1) # type error 3 is not reported | ||
|
||
####def test_ordered_dict(od: typing.Dict[str,int]) -> typing.Dict[str,int]: | ||
#### return 1 #type error 1 | ||
#### | ||
####a = test_ordered_dict(1) #type error 2 | ||
#### | ||
####def test_me(): | ||
#### a = test_ordered_dict(1) # type error 3 is not reported | ||
### |
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,76 @@ | ||
# Stubs for docopt (Python 2) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
|
||
from typing import Any | ||
|
||
class DocoptLanguageError(Exception): ... | ||
|
||
class DocoptExit(SystemExit): | ||
usage = ... # type: Any | ||
def __init__(self, message=''): ... | ||
|
||
class Pattern: | ||
def __eq__(self, other): ... | ||
def __hash__(self): ... | ||
def fix(self): ... | ||
def fix_identities(self, uniq=None): ... | ||
def fix_repeating_arguments(self): ... | ||
@property | ||
def either(self): ... | ||
|
||
class ChildPattern(Pattern): | ||
name = ... # type: Any | ||
value = ... # type: Any | ||
def __init__(self, name, value=None): ... | ||
def flat(self, *types): ... | ||
def match(self, left, collected=None): ... | ||
|
||
class ParentPattern(Pattern): | ||
children = ... # type: Any | ||
def __init__(self, *children): ... | ||
def flat(self, *types): ... | ||
|
||
class Argument(ChildPattern): | ||
def single_match(self, left): ... | ||
@classmethod | ||
def parse(class_, source): ... | ||
|
||
class Command(Argument): | ||
name = ... # type: Any | ||
value = ... # type: Any | ||
def __init__(self, name, value=False): ... | ||
def single_match(self, left): ... | ||
|
||
class Option(ChildPattern): | ||
value = ... # type: Any | ||
def __init__(self, short=None, long=None, argcount=0, value=False): ... | ||
@classmethod | ||
def parse(class_, option_description): ... | ||
def single_match(self, left): ... | ||
@property | ||
def name(self): ... | ||
|
||
class Required(ParentPattern): | ||
def match(self, left, collected=None): ... | ||
|
||
class Optional(ParentPattern): | ||
def match(self, left, collected=None): ... | ||
|
||
class AnyOptions(Optional): ... | ||
|
||
class OneOrMore(ParentPattern): | ||
def match(self, left, collected=None): ... | ||
|
||
class Either(ParentPattern): | ||
def match(self, left, collected=None): ... | ||
|
||
class TokenStream(list): | ||
error = ... # type: Any | ||
def __init__(self, source, error): ... | ||
def move(self): ... | ||
def current(self): ... | ||
|
||
class Dict(dict): ... | ||
|
||
def docopt(doc, argv=None, help=True, version=None, options_first=False): ... |
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,8 @@ | ||
# Stubs for hypothesis (Python 2) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
|
||
from hypothesis._settings import settings as settings, Verbosity as Verbosity | ||
from hypothesis.version import __version_info__ as __version_info__, __version__ as __version__ | ||
from hypothesis.control import assume as assume, note as note, reject as reject | ||
from hypothesis.core import given as given, find as find, example as example, seed as seed |
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,31 @@ | ||
# Stubs for schema (Python 2) | ||
# | ||
# NOTE: This dynamically typed stub was automatically generated by stubgen. | ||
|
||
from typing import Any | ||
|
||
class SchemaError(Exception): | ||
autos = ... # type: Any | ||
errors = ... # type: Any | ||
def __init__(self, autos, errors): ... | ||
@property | ||
def code(self): ... | ||
|
||
class And: | ||
def __init__(self, *args, **kw): ... | ||
def validate(self, data): ... | ||
|
||
class Or(And): | ||
def validate(self, data): ... | ||
|
||
class Use: | ||
def __init__(self, callable_, error=None): ... | ||
def validate(self, data): ... | ||
|
||
def priority(s): ... | ||
|
||
class Schema: | ||
def __init__(self, schema, error=None): ... | ||
def validate(self, data): ... | ||
|
||
class Optional(Schema): ... |
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,3 @@ | ||
from typing import Callable, Any, Union, List, Iterator | ||
def Command(s): # type: (str) -> Callable[...,Union[List[str],Iterator[str]]] | ||
pass |
Empty file.
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,32 @@ | ||
from typing import Dict, Any, Callable, TypeVar | ||
K = TypeVar('K') | ||
V = TypeVar('V') | ||
V2 = TypeVar('V2') | ||
V3 = TypeVar('V3') | ||
def merge(d1, d2): # type: (Dict[K,V], Dict[K,V]) -> Dict[K,V] | ||
pass | ||
|
||
def dissoc(d, k): # type: (Dict[K,V], K) -> Dict[K,V] | ||
pass | ||
|
||
def merge_with(f, d1, d2): # type: (Callable[[V,V2], V3], Dict[K,V], Dict[K,V2]) -> Dict[K,V3] | ||
pass | ||
|
||
def valfilter(f, d): # type: (Callable[[V], bool], Dict[K,V]) -> Dict[K,V] | ||
pass | ||
|
||
|
||
|
||
#from typing import Dict, Any, Callable, TypeVar | ||
#T = TypeVar('T') | ||
#def merge(d1, d2): # type: (Dict[Any,Any], Dict[Any,Any]) -> Dict[Any,Any] | ||
# pass | ||
# | ||
#def dissoc(d, k): # type: (Dict[Any,Any], Any) -> Dict[Any,Any] | ||
# pass | ||
# | ||
#def merge_with(f, d1, d2): # type: (Callable, Dict[Any,Any], Dict[Any,Any]) -> Dict[Any,Any] | ||
# pass | ||
# | ||
#def valfilter(f, d): # type: (Callable, Dict[Any,Any]) -> Dict[Any,Any] | ||
# pass |
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,11 @@ | ||
from typing import Union, Dict, List, NamedTuple, Iterator, BinaryIO | ||
from vcf.model import _Record | ||
|
||
#fields = [("ALT", Union[str, List[str]]), ("REF", str), ("POS", int), ("CHROM", str), ("INFO", Dict[str, Union[int, List[int]]])] | ||
# | ||
#VCFRecord = NamedTuple('VCFRecord', fields) | ||
|
||
VCFRecord = NamedTuple('VCFRecord', [("ALT", Union[str, List[str]]), ("REF", str), ("POS", int), ("CHROM", str), ("INFO", Dict[str, Union[int, List[int]]])] | ||
) | ||
def Reader(s): # type: (BinaryIO) -> Iterator[_Record] | ||
pass |
Oops, something went wrong.