8000 Remove some uses of overload by refi64 · Pull Request #665 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Remove some uses of overload #665

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2015
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove more overload uses
  • Loading branch information
refi64 committed May 14, 2015
commit d0ff77b9eff56bd6243842e4e871c6688c6699e7
12 changes: 3 additions & 9 deletions stubs/3.2/glob.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

# Based on http://docs.python.org/3.2/library/glob.html

from typing import overload, List, Iterator
from typing import List, Iterator, AnyStr

@overload
def glob(pathname: str) -> List[str]: pass
@overload
def glob(pathname: bytes) -> List[bytes]: pass
@overload
def iglob(pathname: str) -> Iterator[str]: pass
@overload
def iglob(pathname: bytes) -> Iterator[bytes]: pass
def glob(pathname: AnyStr) -> List[AnyStr]: pass
def iglob(pathname: AnyStr) -> Iterator[AnyStr]: pass
2 changes: 1 addition & 1 deletion stubs/3.2/posixpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# based on http://docs.python.org/3.2/library/os.path.html

from typing import Any, List, Tuple, IO, overload
from typing import Any, List, Tuple, IO

# ----- os.path variables -----
supports_unicode_filenames = False
Expand Down
18 changes: 5 additions & 13 deletions stubs/3.2/re.py
< 8000 td id="diff-4ab7ee2cc85388e320c01a50344a8c24d1e9735d43ad4003bcad33d73b1631d7R51" data-line-number="51" class="blob-num blob-num-context js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# and http://hg.python.org/cpython/file/618ea5612e83/Lib/re.py

from typing import (
Undefined, List, Iterator, overload, Callable, Tuple, Sequence, Dict,
Undefined, List, Iterator, Callable, Tuple, Sequence, Dict, Union,
Generic, AnyStr, Match, Pattern
)

Expand Down Expand Up @@ -46,20 +46,12 @@ def findall(pattern: AnyStr, string: AnyStr,
def finditer(pattern: AnyStr, string: AnyStr,
flags: int = 0) -> Iterator[Match[AnyStr]]: pass

@overload
def sub(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = 0,
flags: int = 0) -> AnyStr: pass
@overload
def sub(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr],
def sub(pattern: AnyStr, repl: Union[AnyStr, Callable[[Match[AnyStr]], AnyStr]],
string: AnyStr, count: int = 0, flags: int = 0) -> AnyStr: pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string argument needs a default too.


@overload
def subn(pattern: AnyStr, repl: AnyStr, string: AnyStr, count: int = 0,
flags: int = 0) -> Tuple[AnyStr, int]: pass
@overload
def subn(pattern: AnyStr, repl: Callable[[Match[AnyStr]], AnyStr],
string: AnyStr, count: int = 0,
flags: int = 0) -> Tuple[AnyStr, int]: pass
def subn(pattern: AnyStr, repl: Union[AnyStr, Callable[[Match[AnyStr]], AnyStr]],
string: AnyStr, count: int = 0, flags: int = 0) -> Tuple[AnyStr, int]:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comments on sub.


def escape(string: AnyStr) -> AnyStr: pass

Expand Down
4 changes: 1 addition & 3 deletions stubs/3.2/shutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# sometimes they only work partially (broken exception messages), and the test
# cases don't use them.

from typing import (
overload, List, Iterable, Callable, Any, Tuple, Sequence, IO, AnyStr
)
from typing import List, Iterable, Callable, Any, Tuple, Sequence, IO, AnyStr

def copyfileobj(fsrc: IO[AnyStr], fdst: IO[AnyStr],
length: int = None) -> None: pass
Expand Down
17 changes: 4 additions & 13 deletions stubs/3.2/warnings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@

# Based on http://docs.python.org/3.2/library/warnings.html

from typing import overload, Any, List, TextIO
from typing import Any, List, TextIO, Union

@overload
def warn(message: str, category: type = None,
stacklevel: int = 1) -> None: pass
@overload
def warn(message: Warning, category: type = None,
def warn(message: Union[str, Warning], category: type = None,
stacklevel: int = 1) -> None: pass

@overload
def warn_explicit(message: str, category: type, filename: str, lineno: int,
module: str = None, registry: Any = None,
module_globals: Any = None) -> None: pass
@overload
def warn_explicit(message: Warning, category: type, filename: str, lineno: int,
module: str = None, registry: Any = None,
def warn_explicit(message: Union[str, Warning], category: type, filename: str,
lineno: int, module: str = None, registry: Any = None,
module_globals: Any = None) -> None: pass

# logging modifies showwarning => make it a variable.
Expand Down
0