diff --git a/.gitignore b/.gitignore index c28b7513a..763a935ff 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,18 @@ eggs/ *~ \#*\# .desktop + +# virtualenv +venv/ +venv3/ + +# pycharm +.idea/ + +# typshed repo +typeshed/2and3/schema_salad +typeshed/2and3/ruamel/yaml + + +#mypy +.mypy_cache/ diff --git a/Makefile b/Makefile index a6afc3645..032973ca4 100644 --- a/Makefile +++ b/Makefile @@ -152,26 +152,26 @@ list-author-emails: @git log --format='%aN,%aE' | sort -u | grep -v 'root' -mypy: ${PYSOURCES} - rm -Rf typeshed/2.7/ruamel/yaml +mypy2: ${PYSOURCES} + rm -Rf typeshed/2and3/ruamel/yaml ln -s $(shell python -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \ - typeshed/2.7/ruamel/yaml - rm -Rf typeshed/2.7/schema_salad + typeshed/2and3/ruamel/yaml + rm -Rf typeshed/2and3/schema_salad ln -s $(shell python -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \ - typeshed/2.7/schema_salad - MYPYPATH=typeshed/2.7 mypy --py2 --disallow-untyped-calls \ - --warn-redundant-casts --warn-unused-ignores --fast-parser \ + typeshed/2and3/schema_salad + MYPYPATH=$MYPYPATH:typeshed/2.7:typeshed/2and3 mypy --py2 --disallow-untyped-calls \ + --warn-redundant-casts --warn-unused-ignores \ cwltool mypy3: ${PYSOURCES} - rm -Rf typeshed/3/ruamel/yaml + rm -Rf typeshed/2and3/ruamel/yaml ln -s $(shell python3 -c 'from __future__ import print_function; import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \ - typeshed/3/ruamel/yaml - rm -Rf typeshed/3/schema_salad + typeshed/2and3/ruamel/yaml + rm -Rf typeshed/2and3/schema_salad ln -s $(shell python3 -c 'from __future__ import print_function; import schema_salad; import os.path; print(os.path.dirname(schema_salad.__file__))') \ - typeshed/3/schema_salad - MYPYPATH=typeshed/3 mypy --disallow-untyped-calls \ - --warn-redundant-casts --warn-unused-ignores --fast-parser \ + typeshed/2and3/schema_salad + MYPYPATH=$MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \ + --warn-redundant-casts --warn-unused-ignores \ cwltool FORCE: diff --git a/cwlref-runner/setup.py b/cwlref-runner/setup.py index c09ce834f..fcbe7d631 100644 --- a/cwlref-runner/setup.py +++ b/cwlref-runner/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python - +from __future__ import absolute_import import os from setuptools import setup, find_packages diff --git a/cwltool.py b/cwltool.py index 0cdd91a14..45515b58e 100755 --- a/cwltool.py +++ b/cwltool.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +from __future__ import absolute_import """Convienance entry point for cwltool. This can be used instead of the recommended method of `./setup.py install` diff --git a/cwltool/__init__.py b/cwltool/__init__.py index 70d587a69..d41b82221 100644 --- a/cwltool/__init__.py +++ b/cwltool/__init__.py @@ -1 +1,2 @@ +from __future__ import absolute_import __author__ = 'peter.amstutz@curoverse.com' diff --git a/cwltool/__main__.py b/cwltool/__main__.py index 4d84a444f..1420d6953 100644 --- a/cwltool/__main__.py +++ b/cwltool/__main__.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import sys from . import main diff --git a/cwltool/builder.py b/cwltool/builder.py index 0a535800a..d6d393d59 100644 --- a/cwltool/builder.py +++ b/cwltool/builder.py @@ -1,6 +1,8 @@ +from __future__ import absolute_import import copy -from typing import Any, Callable, Text, Type, Union +from typing import Any, Callable, Dict, List, Text, Type, Union +import six from six import iteritems, string_types import avro @@ -15,6 +17,11 @@ from .stdfsaccess import StdFsAccess from .utils import aslist +# if six.PY3: +# AvroSchemaFromJSONData = avro.schema.SchemaFromJSONData +# else: +AvroSchemaFromJSONData = avro.schema.make_avsc_object + CONTENT_LIMIT = 64 * 1024 @@ -86,7 +93,7 @@ def bind_input(self, schema, datum, lead_pos=None, tail_pos=None): elif isinstance(t, dict) and "name" in t and self.names.has_name(t["name"], ""): avsc = self.names.get_name(t["name"], "") else: - avsc = avro.schema.make_avsc_object(t, self.names) + avsc = AvroSchemaFromJSONData(t, self.names) if validate.validate(avsc, datum): schema = copy.deepcopy(schema) schema["type"] = t diff --git a/cwltool/cwlrdf.py b/cwltool/cwlrdf.py index 7b0f6f8fd..fc662db5b 100644 --- a/cwltool/cwlrdf.py +++ b/cwltool/cwlrdf.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from typing import IO, Any, Dict, Text from rdflib import Graph diff --git a/cwltool/docker.py b/cwltool/docker.py index c2ada773f..22a2f49ae 100644 --- a/cwltool/docker.py +++ b/cwltool/docker.py @@ -1,10 +1,11 @@ +from __future__ import absolute_import import logging import os import re import subprocess import sys import tempfile -from typing import Text +from typing import Dict, List, Text import requests @@ -21,7 +22,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False): dockerRequirement["dockerImageId"] = dockerRequirement["dockerPull"] for ln in subprocess.check_output( - ["docker", "images", "--no-trunc", "--all"]).splitlines(): + ["docker", "images", "--no-trunc", "--all"]).decode('utf-8').splitlines(): try: m = re.match(r"^([^ ]+)\s+([^ ]+)\s+([^ ]+)", ln) sp = dockerRequirement["dockerImageId"].split(":") @@ -46,7 +47,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False): pass if not found and pull_image: - cmd = [] # type: List[str] + cmd = [] # type: List[Text] if "dockerPull" in dockerRequirement: cmd = ["docker", "pull", str(dockerRequirement["dockerPull"])] _logger.info(Text(cmd)) @@ -55,8 +56,8 @@ def get_image(dockerRequirement, pull_image, dry_run=False): found = True elif "dockerFile" in dockerRequirement: dockerfile_dir = str(tempfile.mkdtemp()) - with open(os.path.join(dockerfile_dir, "Dockerfile"), "w") as df: - df.write(dockerRequirement["dockerFile"]) + with open(os.path.join(dockerfile_dir, "Dockerfile"), str("w")) as df: + df.write(dockerRequirement["dockerFile"].encode('utf-8')) cmd = ["docker", "build", "--tag=%s" % str(dockerRequirement["dockerImageId"]), dockerfile_dir] _logger.info(Text(cmd)) @@ -69,7 +70,7 @@ def get_image(dockerRequirement, pull_image, dry_run=False): if not dry_run: if os.path.exists(dockerRequirement["dockerLoad"]): _logger.info(u"Loading docker image from %s", dockerRequirement["dockerLoad"]) - with open(dockerRequirement["dockerLoad"], "rb") as f: + with open(dockerRequirement["dockerLoad"], str("rb")) as f: loadproc = subprocess.Popen(cmd, stdin=f, stdout=sys.stderr) else: loadproc = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=sys.stderr) diff --git a/cwltool/docker_uid.py b/cwltool/docker_uid.py index fad871152..90452a2e4 100644 --- a/cwltool/docker_uid.py +++ b/cwltool/docker_uid.py @@ -1,7 +1,8 @@ from __future__ import print_function +from __future__ import absolute_import import subprocess -from typing import Text +from typing import List, Text def docker_vm_uid(): # type: () -> int @@ -91,6 +92,7 @@ def cmd_output_to_int(cmd): # type: (List[Text]) -> int except ValueError: # ValueError is raised if int conversion fails return None + return None def boot2docker_uid(): # type: () -> int diff --git a/cwltool/draft2tool.py b/cwltool/draft2tool.py index ad4fe10ce..e3f2c4776 100644 --- a/cwltool/draft2tool.py +++ b/cwltool/draft2tool.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import copy import hashlib import json @@ -7,7 +8,7 @@ import shutil import tempfile from functools import partial -from typing import Any, Callable, Dict, Generator, Optional, Text, Union, cast +from typing import Any, Callable, Dict, Generator, List, Optional, Set, Text, Union, cast from six import string_types, u @@ -28,6 +29,7 @@ normalizeFilesDirs, shortname, uniquename) from .stdfsaccess import StdFsAccess from .utils import aslist +from six.moves import map ACCEPTLIST_EN_STRICT_RE = re.compile(r"^[a-zA-Z0-9._+-]+$") ACCEPTLIST_EN_RELAXED_RE = re.compile(r".*") # Accept anything @@ -60,7 +62,7 @@ def run(self, **kwargs): # type: (**Any) -> None normalizeFilesDirs(ev) self.output_callback(ev, "success") except Exception as e: - _logger.warn(u"Failed to evaluate expression:\n%s", + _logger.warning(u"Failed to evaluate expression:\n%s", e, exc_info=kwargs.get('debug')) self.output_callback({}, "permanentFail") @@ -224,7 +226,7 @@ def job(self, visit_class([cachebuilder.files, cachebuilder.bindings], ("File", "Directory"), _check_adjust) - cmdline = flatten(map(cachebuilder.generate_arg, cachebuilder.bindings)) + cmdline = flatten(list(map(cachebuilder.generate_arg, cachebuilder.bindings))) (docker_req, docker_is_req) = self.get_requirement("DockerRequirement") if docker_req and kwargs.get("use_container") is not False: dockerimg = docker_req.get("dockerImageId") or docker_req.get("dockerPull") @@ -253,7 +255,7 @@ def job(self, keydict[r["class"]] = r keydictstr = json.dumps(keydict, separators=(',', ':'), sort_keys=True) - cachekey = hashlib.md5(keydictstr).hexdigest() + cachekey = hashlib.md5(keydictstr.encode('utf-8')).hexdigest() _logger.debug("[job %s] keydictstr is %s -> %s", jobname, keydictstr, cachekey) @@ -446,7 +448,7 @@ def register_reader(f): cmd.extend(aslist(arg)) j.command_line = ["/bin/sh", "-c", " ".join(cmd)] else: - j.command_line = flatten(map(builder.generate_arg, builder.bindings)) + j.command_line = flatten(list(map(builder.generate_arg, builder.bindings))) j.pathmapper = builder.pathmapper j.collect_outputs = partial( @@ -535,7 +537,7 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr "class": "File" if fs_access.isfile(g) else "Directory"} for g in fs_access.glob(fs_access.join(outdir, gb))]) except (OSError, IOError) as e: - _logger.warn(Text(e)) + _logger.warning(Text(e)) except: _logger.error("Unexpected error from fs_access", exc_info=True) raise @@ -547,14 +549,14 @@ def collect_output(self, schema, builder, outdir, fs_access, compute_checksum=Tr get_listing(fs_access, files, (ll == "deep_listing")) else: with fs_access.open(files["location"], "rb") as f: - contents = "" + contents = b"" if binding.get("loadContents") or compute_checksum: contents = f.read(CONTENT_LIMIT) if binding.get("loadContents"): files["contents"] = contents if compute_checksum: checksum = hashlib.sha1() - while contents != "": + while contents != b"": checksum.update(contents) contents = f.read(1024 * 1024) files["checksum"] = "sha1$%s" % checksum.hexdigest() diff --git a/cwltool/expression.py b/cwltool/expression.py index b3991a1d7..c92ba315f 100644 --- a/cwltool/expression.py +++ b/cwltool/expression.py @@ -1,29 +1,41 @@ +from __future__ import absolute_import import copy import json import logging import re from typing import Any, AnyStr, Dict, List, Text, Union - +import six from six import u from . import sandboxjs from .errors import WorkflowException +from .utils import bytes2str_in_dicts _logger = logging.getLogger("cwltool") def jshead(engineConfig, rootvars): # type: (List[Text], Dict[Text, Any]) -> Text + + # make sure all the byte strings are converted + # to str in `rootvars` dict. + # TODO: need to make sure the `rootvars dict` + # contains no bytes type in the first place. + if six.PY3: + rootvars = bytes2str_in_dicts(rootvars) # type -> ignore + return u"\n".join(engineConfig + [u"var %s = %s;" % (k, json.dumps(v, indent=4)) for k, v in rootvars.items()]) +# decode all raw strings to unicode seg_symbol = r"""\w+""" seg_single = r"""\['([^']|\\')+'\]""" seg_double = r"""\["([^"]|\\")+"\]""" seg_index = r"""\[[0-9]+\]""" segments = r"(\.%s|%s|%s|%s)" % (seg_symbol, seg_single, seg_double, seg_index) -segment_re = re.compile(segments, flags=re.UNICODE) -param_re = re.compile(r"\((%s)%s*\)$" % (seg_symbol, segments), flags=re.UNICODE) +segment_re = re.compile(u(segments), flags=re.UNICODE) +param_str = r"\((%s)%s*\)$" % (seg_symbol, segments) +param_re = re.compile(u(param_str), flags=re.UNICODE) JSON = Union[Dict[Any, Any], List[Any], Text, int, float, bool, None] @@ -110,7 +122,7 @@ def scanner(scan): # type: (Text) -> List[int] def next_seg(remain, obj): # type: (Text, Any) -> Any if remain: m = segment_re.match(remain) - key = None # type: Union[str, int] + key = None # type: Union[Text, int] if m.group(0)[0] == '.': key = m.group(0)[1:] elif m.group(0)[1] in ("'", '"'): diff --git a/cwltool/factory.py b/cwltool/factory.py index 3f7447d63..4ca2f33c5 100644 --- a/cwltool/factory.py +++ b/cwltool/factory.py @@ -1,6 +1,7 @@ +from __future__ import absolute_import import os from typing import Callable as tCallable -from typing import Any, Text, Tuple, Union +from typing import Any, Dict, Text, Tuple, Union from . import load_tool, main, workflow from .process import Process diff --git a/cwltool/flatten.py b/cwltool/flatten.py index 477444aad..e3c0345ef 100644 --- a/cwltool/flatten.py +++ b/cwltool/flatten.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import from typing import Any, Callable, List, cast # http://rightfootin.blogspot.com/2006/09/more-on-python-flatten.html diff --git a/cwltool/job.py b/cwltool/job.py index 8498c3897..0e34b276c 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -1,4 +1,6 @@ +from __future__ import absolute_import import functools +import io import json import logging import os @@ -8,7 +10,7 @@ import subprocess import sys import tempfile -from typing import (IO, Any, Callable, Iterable, List, MutableMapping, Text, +from typing import (IO, Any, Callable, Dict, Iterable, List, MutableMapping, Text, Tuple, Union, cast) import shellescape @@ -238,7 +240,7 @@ def _execute(self, runtime, env, rm_tmpdir=True, move_outputs="move"): processStatus = "permanentFail" if processStatus != "success": - _logger.warn(u"[job %s] completed %s", self.name, processStatus) + _logger.warning(u"[job %s] completed %s", self.name, processStatus) else: _logger.info(u"[job %s] completed %s", self.name, processStatus) @@ -260,7 +262,7 @@ class CommandLineJob(JobBase): def run(self, pull_image=True, rm_container=True, rm_tmpdir=True, move_outputs="move", **kwargs): - # type: (bool, bool, bool, Text, **Any) -> Union[Tuple[Text, Dict[None, None]], None] + # type: (bool, bool, bool, Text, **Any) -> None self._setup() @@ -317,13 +319,13 @@ def add_volumes(self, pathmapper, runtime, stage_output): shutil.copytree(vol.resolved, vol.target) elif vol.type == "CreateFile": createtmp = os.path.join(host_outdir, os.path.basename(vol.target)) - with open(createtmp, "w") as f: + with open(createtmp, "wb") as f: f.write(vol.resolved.encode("utf-8")) runtime.append(u"--volume=%s:%s:ro" % (createtmp, vol.target)) def run(self, pull_image=True, rm_container=True, rm_tmpdir=True, move_outputs="move", **kwargs): - # type: (bool, bool, bool, Text, **Any) -> Union[Tuple[Text, Dict[None, None]], None] + # type: (bool, bool, bool, Text, **Any) -> None (docker_req, docker_is_req) = get_feature(self, "DockerRequirement") @@ -443,7 +445,7 @@ def _job_popen( rcode = sp.wait() - if isinstance(stdin, file): + if isinstance(stdin, io.IOBase): stdin.close() if stdout is not sys.stderr: @@ -461,6 +463,7 @@ def _job_popen( job_script_contents = SHELL_COMMAND_TEMPLATE env_copy = {} + key = None # type: Union[Text, bytes] for key in env: key = key.encode("utf-8") env_copy[key] = env[key] @@ -477,8 +480,8 @@ def _job_popen( json.dump(job_description, f) try: job_script = os.path.join(job_dir, "run_job.bash") - with open(job_script, "w") as f: - f.write(job_script_contents) + with open(job_script, "wb") as f: + f.write(job_script_contents.encode('utf-8')) job_run = os.path.join(job_dir, "run_job.py") with open(job_run, "w") as f: f.write(PYTHON_RUN_SCRIPT) diff --git a/cwltool/load_tool.py b/cwltool/load_tool.py index b284d32a8..eaed930d5 100644 --- a/cwltool/load_tool.py +++ b/cwltool/load_tool.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import # pylint: disable=unused-import """Loads a CWL document.""" @@ -5,7 +6,7 @@ import os import re import uuid -from typing import Any, Callable, Dict, Text, Tuple, Union, cast +from typing import Any, Callable, Dict, List, Text, Tuple, Union, cast import requests.sessions from six import itervalues, string_types @@ -32,10 +33,10 @@ u"id": u"@id" } -def fetch_document(argsworkflow, # type: Union[Text, dict[Text, Any]] - resolver=None, # type: Callable[[Loader, Union[Text, dict[Text, Any]]], Text] +def fetch_document(argsworkflow, # type: Union[Text, Dict[Text, Any]] + resolver=None, # type: Callable[[Loader, Union[Text, Dict[Text, Any]]], Text] fetcher_constructor=None - # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + # type: Callable[[Dict[Text, Text], requests.sessions.Session], Fetcher] ): # type: (...) -> Tuple[Loader, CommentedMap, Text] """Retrieve a CWL document.""" @@ -135,7 +136,7 @@ def validate_document(document_loader, # type: Loader preprocess_only=False, # type: bool fetcher_constructor=None, skip_schemas=None - # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + # type: Callable[[Dict[Text, Text], requests.sessions.Session], Fetcher] ): # type: (...) -> Tuple[Loader, Names, Union[Dict[Text, Any], List[Dict[Text, Any]]], Dict[Text, Any], Text] """Validate a CWL document.""" @@ -164,7 +165,7 @@ def validate_document(document_loader, # type: Loader r"^(?:cwl:|https://w3id.org/cwl/cwl#)", "", workflowobj["cwlVersion"]) else: - _logger.warn("No cwlVersion found, treating this file as draft-2.") + _logger.warning("No cwlVersion found, treating this file as draft-2.") workflowobj["cwlVersion"] = "draft-2" if workflowobj["cwlVersion"] == "draft-2": @@ -180,8 +181,7 @@ def validate_document(document_loader, # type: Loader if isinstance(avsc_names, Exception): raise avsc_names - processobj = None # type: Union[CommentedMap, CommentedSeq, unicode] - + processobj = None # type: Union[CommentedMap, CommentedSeq, Text] document_loader = Loader(sch_document_loader.ctx, schemagraph=sch_document_loader.graph, idx=document_loader.idx, cache=sch_document_loader.cache, fetcher_constructor=fetcher_constructor, skip_schemas=skip_schemas) @@ -263,11 +263,11 @@ def make_tool(document_loader, # type: Loader def load_tool(argsworkflow, # type: Union[Text, Dict[Text, Any]] makeTool, # type: Callable[..., Process] - kwargs=None, # type: dict + kwargs=None, # type: Dict enable_dev=False, # type: bool strict=True, # type: bool - resolver=None, # type: Callable[[Loader, Union[Text, dict[Text, Any]]], Text] - fetcher_constructor=None # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + resolver=None, # type: Callable[[Loader, Union[Text, Dict[Text, Any]]], Text] + fetcher_constructor=None # type: Callable[[Dict[Text, Text], requests.sessions.Session], Fetcher] ): # type: (...) -> Process diff --git a/cwltool/main.py b/cwltool/main.py index 423d4a893..0f5b19a18 100755 --- a/cwltool/main.py +++ b/cwltool/main.py @@ -1,5 +1,6 @@ #!/usr/bin/env python from __future__ import print_function +from __future__ import absolute_import import argparse import functools @@ -8,11 +9,12 @@ import os import sys import tempfile -from typing import (IO, Any, AnyStr, Callable, Dict, Sequence, Text, Tuple, +from typing import (IO, Any, AnyStr, Callable, Dict, List, Sequence, Text, Tuple, Union, cast) import pkg_resources # part of setuptools import requests +import six import string import ruamel.yaml as yaml @@ -440,7 +442,7 @@ def generate_parser(toolparser, tool, namemap, records): def load_job_order(args, t, stdin, print_input_deps=False, relative_deps=False, stdout=sys.stdout, make_fs_access=None, fetcher_constructor=None): - # type: (argparse.Namespace, Process, IO[Any], bool, bool, IO[Any], Callable[[Text], StdFsAccess], Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher]) -> Union[int, Tuple[Dict[Text, Any], Text]] + # type: (argparse.Namespace, Process, IO[Any], bool, bool, IO[Any], Callable[[Text], StdFsAccess], Callable[[Dict[Text, Text], requests.sessions.Session], Fetcher]) -> Union[int, Tuple[Dict[Text, Any], Text]] job_order_object = None @@ -480,9 +482,9 @@ def load_job_order(args, t, stdin, print_input_deps=False, relative_deps=False, for record_name in records: record = {} record_items = { - k: v for k, v in cmd_line.iteritems() + k: v for k, v in six.iteritems(cmd_line) if k.startswith(record_name)} - for key, value in record_items.iteritems(): + for key, value in six.iteritems(record_items): record[key[len(record_name) + 1:]] = value del cmd_line[key] cmd_line[str(record_name)] = record @@ -581,7 +583,7 @@ def loadref(b, u): def print_pack(document_loader, processobj, uri, metadata): - # type: (Loader, Union[Dict[unicode, Any], List[Dict[unicode, Any]]], unicode, Dict[unicode, Any]) -> str + # type: (Loader, Union[Dict[Text, Any], List[Dict[Text, Any]]], Text, Dict[Text, Any]) -> str packed = pack(document_loader, processobj, uri, metadata) if len(packed["$graph"]) > 1: return json.dumps(packed, indent=4) @@ -599,10 +601,11 @@ def versionstring(): def supportedCWLversions(enable_dev): # type: (bool) -> List[Text] + # ALLUPDATES and UPDATES are dicts if enable_dev: - versions = ALLUPDATES.keys() + versions = list(ALLUPDATES) else: - versions = UPDATES.keys() + versions = list(UPDATES) versions.sort() return versions @@ -617,7 +620,7 @@ def main(argsl=None, # type: List[str] versionfunc=versionstring, # type: Callable[[], Text] job_order_object=None, # type: Union[Tuple[Dict[Text, Any], Text], int] make_fs_access=StdFsAccess, # type: Callable[[Text], StdFsAccess] - fetcher_constructor=None, # type: Callable[[Dict[unicode, unicode], requests.sessions.Session], Fetcher] + fetcher_constructor=None, # type: Callable[[Dict[Text, Text], requests.sessions.Session], Fetcher] resolver=tool_resolver, logger_handler=None, custom_schema_callback=None # type: Callable[[], None] @@ -639,7 +642,7 @@ def main(argsl=None, # type: List[str] # If caller provided custom arguments, it may be not every expected # option is set, so fill in no-op defaults to avoid crashing when # dereferencing them in args. - for k, v in {'print_deps': False, + for k, v in six.iteritems({'print_deps': False, 'print_pre': False, 'print_rdf': False, 'print_dot': False, @@ -667,7 +670,7 @@ def main(argsl=None, # type: List[str] 'enable_ga4gh_tool_registry': False, 'ga4gh_tool_registries': [], 'find_default_container': None - }.iteritems(): + }): if not hasattr(args, k): setattr(args, k, v) @@ -829,7 +832,7 @@ def locToPath(p): visit_class(out, ("File", "Directory"), locToPath) - if isinstance(out, basestring): + if isinstance(out, six.string_types): stdout.write(out) else: stdout.write(json.dumps(out, indent=4)) @@ -837,7 +840,7 @@ def locToPath(p): stdout.flush() if status != "success": - _logger.warn(u"Final process status is %s", status) + _logger.warning(u"Final process status is %s", status) return 1 else: _logger.info(u"Final process status is %s", status) @@ -855,7 +858,7 @@ def locToPath(p): except WorkflowException as exc: _logger.error( u"Workflow error, try again with --debug for more " - "information:\n%s", strip_dup_lineno(unicode(exc)), exc_info=args.debug) + "information:\n%s", strip_dup_lineno(six.text_type(exc)), exc_info=args.debug) return 1 except Exception as exc: _logger.error( diff --git a/cwltool/mutation.py b/cwltool/mutation.py index 0d389f046..d7f3dbee9 100644 --- a/cwltool/mutation.py +++ b/cwltool/mutation.py @@ -1,5 +1,6 @@ +from __future__ import absolute_import from collections import namedtuple -from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast +from typing import Any, Callable, Dict, Generator, Iterable, List, Text, Union, cast from .errors import WorkflowException diff --git a/cwltool/pack.py b/cwltool/pack.py index bf1114b65..b51d7ad56 100644 --- a/cwltool/pack.py +++ b/cwltool/pack.py @@ -1,10 +1,12 @@ +from __future__ import absolute_import import copy -from typing import Any, Callable, Dict, Text, Union, cast +from typing import Any, Callable, Dict, List, Set, Text, Union, cast from schema_salad.ref_resolver import Loader from six.moves import urllib from .process import shortname, uniquename +import six def flatten_deps(d, files): # type: (Any, Set[Text]) -> None @@ -25,7 +27,7 @@ def find_run(d, loadref, runs): # type: (Any, Callable[[Text, Text], Union[Dict for s in d: find_run(s, loadref, runs) elif isinstance(d, dict): - if "run" in d and isinstance(d["run"], (str, unicode)): + if "run" in d and isinstance(d["run"], six.string_types): if d["run"] not in runs: runs.add(d["run"]) find_run(loadref(None, d["run"]), loadref, runs) @@ -39,7 +41,7 @@ def find_ids(d, ids): # type: (Any, Set[Text]) -> None find_ids(s, ids) elif isinstance(d, dict): for i in ("id", "name"): - if i in d and isinstance(d[i], (str, unicode)): + if i in d and isinstance(d[i], six.string_types): ids.add(d[i]) for s in d.values(): find_ids(s, ids) @@ -49,7 +51,7 @@ def replace_refs(d, rewrite, stem, newstem): # type: (Any, Dict[Text, Text], Text, Text) -> None if isinstance(d, list): for s, v in enumerate(d): - if isinstance(v, (str, unicode)): + if isinstance(v, six.string_types): if v in rewrite: d[s] = rewrite[v] elif v.startswith(stem): @@ -58,7 +60,7 @@ def replace_refs(d, rewrite, stem, newstem): replace_refs(v, rewrite, stem, newstem) elif isinstance(d, dict): for s, v in d.items(): - if isinstance(v, (str, unicode)): + if isinstance(v, six.string_types): if v in rewrite: d[s] = rewrite[v] elif v.startswith(stem): diff --git a/cwltool/pathmapper.py b/cwltool/pathmapper.py index f77053df6..13559cff3 100644 --- a/cwltool/pathmapper.py +++ b/cwltool/pathmapper.py @@ -1,10 +1,11 @@ +from __future__ import absolute_import import collections import logging import os import stat import uuid from functools import partial -from typing import Any, Callable, Iterable, Set, Text, Tuple, Union +from typing import Any, Callable, Dict, Iterable, List, Set, Text, Tuple, Union import schema_salad.validate as validate from schema_salad.ref_resolver import uri_file_path @@ -235,10 +236,10 @@ def mapper(self, src): # type: (Text) -> MapperEnt return self._pathmap[src] def files(self): # type: () -> List[Text] - return self._pathmap.keys() + return list(self._pathmap.keys()) def items(self): # type: () -> List[Tuple[Text, MapperEnt]] - return self._pathmap.items() + return list(self._pathmap.items()) def reversemap(self, target): # type: (Text) -> Tuple[Text, Text] for k, v in self._pathmap.items(): diff --git a/cwltool/process.py b/cwltool/process.py index 04d7c6e4d..3962635ab 100644 --- a/cwltool/process.py +++ b/cwltool/process.py @@ -1,3 +1,5 @@ +from __future__ import absolute_import + import abc import copy import errno @@ -9,23 +11,25 @@ import shutil import stat import tempfile -import urlparse import uuid from collections import Iterable -from typing import (Any, AnyStr, Callable, Dict, Generator, List, Text, Tuple, - Union, cast) - -from pkg_resources import resource_stream -from rdflib import Graph, URIRef -from rdflib.namespace import OWL, RDFS +from functools import cmp_to_key +from typing import (Any, Callable, Dict, Generator, List, Set, Text, + Tuple, Union, cast) import avro.schema import schema_salad.schema import schema_salad.validate as validate +import six +from pkg_resources import resource_stream +from rdflib import Graph, URIRef +from rdflib.namespace import OWL, RDFS from ruamel.yaml.comments import CommentedMap, CommentedSeq from schema_salad.ref_resolver import Loader, file_uri from schema_salad.sourceline import SourceLine +from six.moves import urllib +from .utils import cmp_like_py2 from .builder import Builder from .errors import UnsupportedRequirement, WorkflowException from .pathmapper import (PathMapper, adjustDirObjs, get_listing, @@ -33,9 +37,14 @@ from .stdfsaccess import StdFsAccess from .utils import aslist, get_feature +# if six.PY3: +# AvroSchemaFromJSONData = avro.schema.SchemaFromJSONData +# else: +AvroSchemaFromJSONData = avro.schema.make_avsc_object class LogAsDebugFilter(logging.Filter): - def __init__(self, name, parent): # type: (str, logging.Logger) -> None + def __init__(self, name, parent): # type: (Text, logging.Logger) -> None + name = str(name) super(LogAsDebugFilter, self).__init__(name) self.parent = parent @@ -120,7 +129,7 @@ def get_schema(version): if version in SCHEMA_CACHE: return SCHEMA_CACHE[version] - cache = {} # type: Dict[Text, Text] + cache = {} # type: Dict[Text, Union[bytes, Text]] version = version.split("#")[-1] if '.dev' in version: version = ".".join(version.split(".")[:-1]) @@ -156,7 +165,7 @@ def get_schema(version): def shortname(inputid): # type: (Text) -> Text - d = urlparse.urlparse(inputid) + d = urllib.parse.urlparse(inputid) if d.fragment: return d.fragment.split(u"/")[-1] else: @@ -215,7 +224,7 @@ def stageFiles(pm, stageFunc, ignoreWritable=False): else: shutil.copytree(p.resolved, p.target) elif p.type == "CreateFile" and not ignoreWritable: - with open(p.target, "w") as n: + with open(p.target, "wb") as n: n.write(p.resolved.encode("utf-8")) @@ -387,9 +396,7 @@ def avroize_type(field_type, name_prefix=""): avroize_type(field_type["items"], name_prefix) return field_type -class Process(object): - __metaclass__ = abc.ABCMeta - +class Process(six.with_metaclass(abc.ABCMeta, object)): # type: ignore def __init__(self, toolpath_object, **kwargs): # type: (Dict[Text, Any], **Any) -> None """ @@ -444,8 +451,8 @@ def __init__(self, toolpath_object, **kwargs): sdtypes = sd["types"] av = schema_salad.schema.make_valid_avro(sdtypes, {t["name"]: t for t in avroize_type(sdtypes)}, set()) for i in av: - self.schemaDefs[i["name"]] = i - avro.schema.make_avsc_object(av, self.names) + self.schemaDefs[i["name"]] = i # type: ignore + AvroSchemaFromJSONData(av, self.names) # type: ignore # Build record schema from inputs self.inputs_record_schema = { @@ -475,16 +482,16 @@ def __init__(self, toolpath_object, **kwargs): self.outputs_record_schema["fields"].append(c) try: - self.inputs_record_schema = cast(Dict[unicode, Any], schema_salad.schema.make_valid_avro(self.inputs_record_schema, {}, set())) - avro.schema.make_avsc_object(self.inputs_record_schema, self.names) + self.inputs_record_schema = cast(Dict[six.text_type, Any], schema_salad.schema.make_valid_avro(self.inputs_record_schema, {}, set())) + AvroSchemaFromJSONData(self.inputs_record_schema, self.names) except avro.schema.SchemaParseException as e: raise validate.ValidationException(u"Got error `%s` while processing inputs of %s:\n%s" % (Text(e), self.tool["id"], json.dumps(self.inputs_record_schema, indent=4))) try: - self.outputs_record_schema = cast(Dict[unicode, Any], schema_salad.schema.make_valid_avro(self.outputs_record_schema, {}, set())) - avro.schema.make_avsc_object(self.outputs_record_schema, self.names) + self.outputs_record_schema = cast(Dict[six.text_type, Any], schema_salad.schema.make_valid_avro(self.outputs_record_schema, {}, set())) + AvroSchemaFromJSONData(self.outputs_record_schema, self.names) except avro.schema.SchemaParseException as e: raise validate.ValidationException(u"Got error `%s` while processing outputs of %s:\n%s" % (Text(e), self.tool["id"], @@ -594,15 +601,21 @@ def _init_job(self, joborder, **kwargs): cm.lc.filename = fn builder.bindings.append(cm) - builder.bindings.sort(key=lambda a: a["position"]) - + # use python2 like sorting of heterogeneous lists + # (containing str and int types), + # TODO: unify for both runtime + if six.PY3: + key = cmp_to_key(cmp_like_py2) + else: # PY2 + key = lambda dict: dict["position"] + builder.bindings.sort(key=key) builder.resources = self.evalResources(builder, kwargs) builder.job_script_provider = kwargs.get("job_script_provider", None) return builder def evalResources(self, builder, kwargs): - # type: (Builder, Dict[AnyStr, Any]) -> Dict[Text, Union[int, Text]] + # type: (Builder, Dict[str, Any]) -> Dict[Text, Union[int, Text]] resourceReq, _ = self.get_requirement("ResourceRequirement") if resourceReq is None: resourceReq = {} @@ -734,21 +747,21 @@ def mergedirs(listing): ents[e["basename"]] = e elif e["class"] == "Directory" and e.get("listing"): ents[e["basename"]].setdefault("listing", []).extend(e["listing"]) - for e in ents.itervalues(): + for e in six.itervalues(ents): if e["class"] == "Directory" and "listing" in e: e["listing"] = mergedirs(e["listing"]) - r.extend(ents.itervalues()) + r.extend(six.itervalues(ents)) return r -def scandeps(base, doc, reffields, urlfields, loadref, urljoin=urlparse.urljoin): +def scandeps(base, doc, reffields, urlfields, loadref, urljoin=urllib.parse.urljoin): # type: (Text, Any, Set[Text], Set[Text], Callable[[Text, Text], Any], Callable[[Text, Text], Text]) -> List[Dict[Text, Text]] r = [] # type: List[Dict[Text, Text]] deps = None # type: Dict[Text, Any] if isinstance(doc, dict): if "id" in doc: if doc["id"].startswith("file://"): - df, _ = urlparse.urldefrag(doc["id"]) + df, _ = urllib.parse.urldefrag(doc["id"]) if base != df: r.append({ "class": "File", @@ -775,7 +788,7 @@ def scandeps(base, doc, reffields, urlfields, loadref, urljoin=urlparse.urljoin) elif doc["class"] == "File" and "secondaryFiles" in doc: r.extend(scandeps(base, doc["secondaryFiles"], reffields, urlfields, loadref, urljoin=urljoin)) - for k, v in doc.iteritems(): + for k, v in six.iteritems(doc): if k in reffields: for u in aslist(v): if isinstance(u, dict): @@ -818,7 +831,7 @@ def compute_checksums(fs_access, fileobj): checksum = hashlib.sha1() with fs_access.open(fileobj["location"], "rb") as f: contents = f.read(1024 * 1024) - while contents != "": + while contents != b"": checksum.update(contents) contents = f.read(1024 * 1024) f.seek(0, 2) diff --git a/cwltool/resolver.py b/cwltool/resolver.py index 98571e183..fab6b0bcb 100644 --- a/cwltool/resolver.py +++ b/cwltool/resolver.py @@ -1,6 +1,8 @@ +from __future__ import absolute_import import logging import os -import urllib + +from six.moves import urllib from schema_salad.ref_resolver import file_uri @@ -40,7 +42,7 @@ def resolve_ga4gh_tool(document_loader, uri): if not version: version = "latest" for reg in ga4gh_tool_registries: - ds = "{0}/api/ga4gh/v1/tools/{1}/versions/{2}/plain-CWL/descriptor".format(reg, urllib.quote(path, ""), urllib.quote(version, "")) + ds = "{0}/api/ga4gh/v1/tools/{1}/versions/{2}/plain-CWL/descriptor".format(reg, urllib.parse.quote(path, ""), urllib.parse.quote(version, "")) try: resp = document_loader.session.head(ds) resp.raise_for_status() diff --git a/cwltool/sandboxjs.py b/cwltool/sandboxjs.py index 0cab56a0b..c3960daa2 100644 --- a/cwltool/sandboxjs.py +++ b/cwltool/sandboxjs.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import errno import json import logging @@ -10,6 +11,7 @@ from pkg_resources import resource_stream +import six class JavascriptException(Exception): pass @@ -79,7 +81,7 @@ def new_js_proc(): nodeimg = "node:slim" global have_node_slim if not have_node_slim: - dockerimgs = subprocess.check_output(["docker", "images", nodeimg]) + dockerimgs = subprocess.check_output(["docker", "images", nodeimg]).decode('utf-8') if len(dockerimgs.split("\n")) <= 1: nodejsimg = subprocess.check_output(["docker", "pull", nodeimg]) _logger.info("Pulled Docker image %s %s", nodeimg, nodejsimg) @@ -122,7 +124,7 @@ def execjs(js, jslib, timeout=None, debug=False): # type: (Union[Mapping, Text] nodejs = localdata.proc fn = u"\"use strict\";\n%s\n(function()%s)()" %\ - (jslib, js if isinstance(js, basestring) and len(js) > 1 and js[0] == '{' else ("{return (%s);}" % js)) + (jslib, js if isinstance(js, six.string_types) and len(js) > 1 and js[0] == '{' else ("{return (%s);}" % js)) killed = [] @@ -139,7 +141,7 @@ def term(): tm = threading.Timer(timeout, term) tm.start() - stdin_buf = BytesIO(json.dumps(fn) + "\n") + stdin_buf = BytesIO((json.dumps(fn) + "\n").encode('utf-8')) stdout_buf = BytesIO() stderr_buf = BytesIO() @@ -161,7 +163,7 @@ def term(): pipes[1].write(b) else: rselect.remove(pipes[0]) - if stdout_buf.getvalue().endswith("\n"): + if stdout_buf.getvalue().endswith("\n".encode()): rselect = [] except OSError as e: break @@ -180,7 +182,7 @@ def fn_linenum(): # type: () -> Text lines = lines[-maxlines:] return u"\n".join(u"%02i %s" % (i + ofs + 1, b) for i, b in enumerate(lines)) - def stdfmt(data): # type: (unicode) -> unicode + def stdfmt(data): # type: (Text) -> Text if "\n" in data: return "\n" + data.strip() return data @@ -189,9 +191,9 @@ def stdfmt(data): # type: (unicode) -> unicode if debug: info = u"returncode was: %s\nscript was:\n%s\nstdout was: %s\nstderr was: %s\n" %\ - (nodejs.returncode, fn_linenum(), stdfmt(stdoutdata), stdfmt(stderrdata)) + (nodejs.returncode, fn_linenum(), stdfmt(stdoutdata.decode('utf-8')), stdfmt(stderrdata.decode('utf-8'))) else: - info = stdfmt(stderrdata) + info = stdfmt(stderrdata.decode('utf-8')) if nodejs.poll() not in (None, 0): if killed: @@ -200,7 +202,7 @@ def stdfmt(data): # type: (unicode) -> unicode raise JavascriptException(info) else: try: - return json.loads(stdoutdata) + return json.loads(stdoutdata.decode('utf-8')) except ValueError as e: raise JavascriptException(u"%s\nscript was:\n%s\nstdout was: '%s'\nstderr was: '%s'\n" % (e, fn_linenum(), stdoutdata, stderrdata)) diff --git a/cwltool/software_requirements.py b/cwltool/software_requirements.py index 7e258063e..535b2930e 100644 --- a/cwltool/software_requirements.py +++ b/cwltool/software_requirements.py @@ -6,7 +6,7 @@ Homebrew, Conda, custom scripts, environment modules. We'd be happy to find ways to adapt new packages managers and such as well. """ - +from __future__ import absolute_import import argparse import os import string diff --git a/cwltool/stdfsaccess.py b/cwltool/stdfsaccess.py index 843bb784e..84056c0e5 100644 --- a/cwltool/stdfsaccess.py +++ b/cwltool/stdfsaccess.py @@ -1,14 +1,15 @@ +from __future__ import absolute_import import glob import os -import urllib -from typing import BinaryIO, Text +from typing import BinaryIO, List, Text, IO +import six +from six.moves import urllib from schema_salad.ref_resolver import file_uri, uri_file_path - def abspath(src, basedir): # type: (Text, Text) -> Text if src.startswith(u"file://"): - ab = unicode(uri_file_path(str(src))) + ab = six.text_type(uri_file_path(str(src))) else: ab = src if os.path.isabs(src) else os.path.join(basedir, src) return ab @@ -23,7 +24,7 @@ def _abs(self, p): # type: (Text) -> Text def glob(self, pattern): # type: (Text) -> List[Text] return [file_uri(str(self._abs(l))) for l in glob.glob(self._abs(pattern))] - def open(self, fn, mode): # type: (Text, Text) -> BinaryIO + def open(self, fn, mode): # type: (Text, str) -> IO[bytes] return open(self._abs(fn), mode) def exists(self, fn): # type: (Text) -> bool @@ -36,7 +37,7 @@ def isdir(self, fn): # type: (Text) -> bool return os.path.isdir(self._abs(fn)) def listdir(self, fn): # type: (Text) -> List[Text] - return [abspath(urllib.quote(str(l)), fn) for l in os.listdir(self._abs(fn))] + return [abspath(urllib.parse.quote(str(l)), fn) for l in os.listdir(self._abs(fn))] def join(self, path, *paths): # type: (Text, *Text) -> Text return os.path.join(path, *paths) diff --git a/cwltool/update.py b/cwltool/update.py index bb6a60843..bb5e95c54 100644 --- a/cwltool/update.py +++ b/cwltool/update.py @@ -1,18 +1,19 @@ +from __future__ import absolute_import import copy import json import re import traceback -import urlparse from typing import (Any, Callable, Dict, Text, # pylint: disable=unused-import Tuple, Union) +import six +from six.moves import urllib import schema_salad.validate from ruamel.yaml.comments import CommentedMap, CommentedSeq from schema_salad.ref_resolver import Loader from .utils import aslist - def findId(doc, frg): # type: (Any, Any) -> Dict if isinstance(doc, dict): if "id" in doc and doc["id"] == frg: @@ -49,7 +50,7 @@ def _draft2toDraft3dev1(doc, loader, baseuri, update_steps=True): try: if isinstance(doc, dict): if "import" in doc: - imp = urlparse.urljoin(baseuri, doc["import"]) + imp = urllib.parse.urljoin(baseuri, doc["import"]) impLoaded = loader.fetch(imp) r = None # type: Dict[Text, Any] if isinstance(impLoaded, list): @@ -59,14 +60,14 @@ def _draft2toDraft3dev1(doc, loader, baseuri, update_steps=True): else: raise Exception("Unexpected code path.") r["id"] = imp - _, frag = urlparse.urldefrag(imp) + _, frag = urllib.parse.urldefrag(imp) if frag: frag = "#" + frag r = findId(r, frag) return _draft2toDraft3dev1(r, loader, imp) if "include" in doc: - return loader.fetch_text(urlparse.urljoin(baseuri, doc["include"])) + return loader.fetch_text(urllib.parse.urljoin(baseuri, doc["include"])) for typename in ("type", "items"): if typename in doc: @@ -146,7 +147,7 @@ def _updateDev2Script(ent): # type: (Any) -> Any def _draftDraft3dev1toDev2(doc, loader, baseuri): # type: (Any, Loader, Text) -> Any doc = _updateDev2Script(doc) - if isinstance(doc, basestring): + if isinstance(doc, six.string_types): return doc # Convert expressions @@ -204,7 +205,7 @@ def _draftDraft3dev2toDev3(doc, loader, baseuri): if doc["@import"][0] == "#": return doc["@import"] else: - imp = urlparse.urljoin(baseuri, doc["@import"]) + imp = urllib.parse.urljoin(baseuri, doc["@import"]) impLoaded = loader.fetch(imp) r = {} # type: Dict[Text, Any] if isinstance(impLoaded, list): @@ -214,14 +215,14 @@ def _draftDraft3dev2toDev3(doc, loader, baseuri): else: raise Exception("Unexpected code path.") r["id"] = imp - frag = urlparse.urldefrag(imp)[1] + frag = urllib.parse.urldefrag(imp)[1] if frag: frag = "#" + frag r = findId(r, frag) return _draftDraft3dev2toDev3(r, loader, imp) if "@include" in doc: - return loader.fetch_text(urlparse.urljoin(baseuri, doc["@include"])) + return loader.fetch_text(urllib.parse.urljoin(baseuri, doc["@include"])) for a in doc: doc[a] = _draftDraft3dev2toDev3(doc[a], loader, baseuri) @@ -252,7 +253,7 @@ def traverseImport(doc, loader, baseuri, func): if doc["$import"][0] == "#": return doc["$import"] else: - imp = urlparse.urljoin(baseuri, doc["$import"]) + imp = urllib.parse.urljoin(baseuri, doc["$import"]) impLoaded = loader.fetch(imp) r = {} # type: Dict[Text, Any] if isinstance(impLoaded, list): @@ -262,7 +263,7 @@ def traverseImport(doc, loader, baseuri, func): else: raise Exception("Unexpected code path.") r["id"] = imp - _, frag = urlparse.urldefrag(imp) + _, frag = urllib.parse.urldefrag(imp) if frag: frag = "#" + frag r = findId(r, frag) @@ -349,7 +350,7 @@ def _draft3toDraft4dev1(doc, loader, baseuri): if isinstance(doc, dict): if "class" in doc and doc["class"] == "Workflow": def fixup(f): # type: (Text) -> Text - doc, frg = urlparse.urldefrag(f) + doc, frg = urllib.parse.urldefrag(f) frg = '/'.join(frg.rsplit('.', 1)) return doc + "#" + frg @@ -537,7 +538,7 @@ def checkversion(doc, metadata, enable_dev): "Update your document to a stable version (%s) or use " "--enable-dev to enable support for development and " "deprecated versions." % (version, ", ".join( - UPDATES.keys()))) + list(UPDATES.keys())))) else: raise schema_salad.validate.ValidationException( u"Unrecognized version %s" % version) diff --git a/cwltool/utils.py b/cwltool/utils.py index 8f341c0a9..da71c9699 100644 --- a/cwltool/utils.py +++ b/cwltool/utils.py @@ -1,6 +1,9 @@ +from __future__ import absolute_import + # no imports from cwltool allowed -from typing import Any, Tuple +from six.moves import zip_longest +from typing import Any, Dict, List, Tuple, Text, Union def aslist(l): # type: (Any) -> List[Any] @@ -18,3 +21,58 @@ def get_feature(self, feature): # type: (Any, Any) -> Tuple[Any, bool] if t["class"] == feature: return (t, False) return (None, None) + +# comparision function to be used in sorting +# python3 doesn't allow sorting of different +# types like str() and int(). +# this function re-creates sorting nature in py2 +# of heterogeneous list of `int` and `str` +def cmp_like_py2(dict1, dict2): # type: (Dict[Text, Any], Dict[Text, Any]) -> int + # extract lists from both dicts + a, b = dict1["position"], dict2["position"] + # iterate through both list till max of their size + for i,j in zip_longest(a,b): + if i == j: + continue + # in case 1st list is smaller + # should come first in sorting + if i is None: + return -1 + # if 1st list is longer, + # it should come later in sort + elif j is None: + return 1 + + # if either of the list contains str element + # at any index, both should be str before comparing + if isinstance(i, str) or isinstance(j, str): + return 1 if str(i) > str(j) else -1 + # int comparison otherwise + return 1 if i > j else -1 + # if both lists are equal + return 0 + +# util function to convert any present byte string +# to unicode string. input is a dict of nested dicts and lists +def bytes2str_in_dicts(a): + # type: (Union[Dict[Text, Any], List[Any], Any]) -> Union[Text, List[Any], Dict[Text, Any]] + + # if input is dict, recursively call for each value + if isinstance(a, dict): + for k, v in dict.items(a): + a[k] = bytes2str_in_dicts(v) + return a + + # if list, iterate through list and fn call + # for all its elements + if isinstance(a, list): + for idx, value in enumerate(a): + a[idx] = bytes2str_in_dicts(value) + return a + + # if value is bytes, return decoded string, + elif isinstance(a, bytes): + return a.decode('utf-8') + + # simply return elements itself + return a diff --git a/cwltool/workflow.py b/cwltool/workflow.py index c671f3c5a..15568117b 100644 --- a/cwltool/workflow.py +++ b/cwltool/workflow.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import copy import functools import json @@ -5,7 +6,7 @@ import random import tempfile from collections import namedtuple -from typing import Any, Callable, Generator, Iterable, List, Text, Union, cast +from typing import Any, Callable, Dict, Generator, Iterable, List, Text, Union, cast import schema_salad.validate as validate from ruamel.yaml.comments import CommentedMap, CommentedSeq @@ -16,6 +17,8 @@ from .load_tool import load_tool from .process import Process, shortname, uniquename from .utils import aslist +import six +from six.moves import range _logger = logging.getLogger("cwltool") @@ -176,7 +179,7 @@ def _rec_fields(rec): # type: (Dict[Text, Any]) -> Dict[Text, Any] srcfields = _rec_fields(src) sinkfields = _rec_fields(sink) - for key in sinkfields.iterkeys(): + for key in six.iterkeys(sinkfields): if (not can_assign_src_to_sink( srcfields.get(key, "null"), sinkfields.get(key, "null"), strict) and sinkfields.get(key) is not None): @@ -311,7 +314,7 @@ def receive_output(self, step, outputparms, final_output_callback, jobout, proce if self.processStatus != "permanentFail": self.processStatus = processStatus - _logger.warn(u"[%s] completed %s", step.name, processStatus) + _logger.warning(u"[%s] completed %s", step.name, processStatus) else: _logger.info(u"[%s] completed %s", step.name, processStatus) @@ -352,11 +355,11 @@ def try_make_job(self, step, final_output_callback, **kwargs): raise WorkflowException( "Workflow step contains valueFrom but StepInputExpressionRequirement not in requirements") - vfinputs = {shortname(k): v for k, v in inputobj.iteritems()} + vfinputs = {shortname(k): v for k, v in six.iteritems(inputobj)} def postScatterEval(io): # type: (Dict[Text, Any]) -> Dict[Text, Any] - shortio = {shortname(k): v for k, v in io.iteritems()} + shortio = {shortname(k): v for k, v in six.iteritems(io)} def valueFromFunc(k, v): # type: (Any, Any) -> Any if k in valueFrom: @@ -378,7 +381,7 @@ def valueFromFunc(k, v): # type: (Any, Any) -> Any tot = 1 emptyscatter = [shortname(s) for s in scatter if len(inputobj[s]) == 0] if emptyscatter: - _logger.warn(u"[job %s] Notice: scattering over empty input in '%s'. All outputs will be empty.", step.name, "', '".join(emptyscatter)) + _logger.warning(u"[job %s] Notice: scattering over empty input in '%s'. All outputs will be empty.", step.name, "', '".join(emptyscatter)) if method == "dotproduct" or method is None: jobs = dotproduct_scatter(step, inputobj, scatter, @@ -606,8 +609,8 @@ def static_checker(workflow_inputs, workflow_outputs, step_inputs, step_outputs) all_exception_msg = "\n".join(exception_msgs) if warnings: - _logger.warn("Workflow checker warning:") - _logger.warn(all_warning_msg) + _logger.warning("Workflow checker warning:") + _logger.warning(all_warning_msg) if exceptions: raise validate.ValidationException(all_exception_msg) @@ -672,11 +675,11 @@ def __init__(self, toolpath_object, pos, **kwargs): for stepfield, toolfield in (("in", "inputs"), ("out", "outputs")): toolpath_object[toolfield] = [] for n, step_entry in enumerate(toolpath_object[stepfield]): - if isinstance(step_entry, (str, unicode)): + if isinstance(step_entry, six.string_types): param = CommentedMap() # type: CommentedMap inputid = step_entry else: - param = CommentedMap(step_entry.iteritems()) + param = CommentedMap(six.iteritems(step_entry)) inputid = step_entry["id"] shortinputid = shortname(inputid) @@ -754,7 +757,7 @@ def __init__(self, toolpath_object, pos, **kwargs): else: nesting = 1 - for r in xrange(0, nesting): + for r in range(0, nesting): for op in outputparms: op["type"] = {"type": "array", "items": op["type"]} self.tool["inputs"] = inputparms @@ -834,7 +837,7 @@ def setTotal(self, total): # type: (int) -> None def parallel_steps(steps, rc, kwargs): # type: (List[Generator], ReceiveScatterOutput, Dict[str, Any]) -> Generator while rc.completed < rc.total: made_progress = False - for index in xrange(len(steps)): + for index in range(len(steps)): step = steps[index] if kwargs.get("on_error", "stop") == "stop" and rc.processStatus != "success": break diff --git a/tests/test_check.py b/tests/test_check.py index 83a49ab9d..4e8b13efc 100644 --- a/tests/test_check.py +++ b/tests/test_check.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest import cwltool.expression as expr diff --git a/tests/test_examples.py b/tests/test_examples.py index abaa5580e..5f26639ba 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest import cwltool.expression as expr diff --git a/tests/test_ext.py b/tests/test_ext.py index ff65690c1..dedfa4d74 100644 --- a/tests/test_ext.py +++ b/tests/test_ext.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import os import shutil import tempfile diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 8d75b2f54..29b5350d2 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest from six.moves import urllib @@ -34,7 +35,7 @@ def check_exists(self, url): # type: (unicode) -> bool else: return False - def urljoin(self, base, url): + def urljoin(self, base, url): urlsp = urllib.parse.urlsplit(url) if urlsp.scheme: return url diff --git a/tests/test_js_sandbox.py b/tests/test_js_sandbox.py index bf32a7acf..e2ea13759 100644 --- a/tests/test_js_sandbox.py +++ b/tests/test_js_sandbox.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest # we should modify the subprocess imported from cwltool.sandboxjs diff --git a/tests/test_pack.py b/tests/test_pack.py index fca1d45c3..e49cd21e3 100644 --- a/tests/test_pack.py +++ b/tests/test_pack.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import json import os import unittest diff --git a/tests/test_pathmapper.py b/tests/test_pathmapper.py index f9a5d3fe5..ac73d82bb 100644 --- a/tests/test_pathmapper.py +++ b/tests/test_pathmapper.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest from cwltool.pathmapper import PathMapper, normalizeFilesDirs diff --git a/tests/test_relax_path_checks.py b/tests/test_relax_path_checks.py index 4012d0a1e..559c11099 100644 --- a/tests/test_relax_path_checks.py +++ b/tests/test_relax_path_checks.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest from tempfile import NamedTemporaryFile @@ -24,7 +25,7 @@ class ToolArgparse(unittest.TestCase): ''' def test_spaces_in_input_files(self): - with NamedTemporaryFile() as f: + with NamedTemporaryFile(mode='w') as f: f.write(self.script) f.flush() with NamedTemporaryFile(prefix="test with spaces") as spaces: diff --git a/tests/test_toolargparse.py b/tests/test_toolargparse.py index 8e0d5bb2c..ad2cd55ba 100644 --- a/tests/test_toolargparse.py +++ b/tests/test_toolargparse.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import unittest from tempfile import NamedTemporaryFile @@ -65,7 +66,7 @@ class ToolArgparse(unittest.TestCase): ''' def test_help(self): - with NamedTemporaryFile() as f: + with NamedTemporaryFile(mode='w') as f: f.write(self.script) f.flush() self.assertEquals(main(["--debug", f.name, '--input', @@ -74,7 +75,7 @@ def test_help(self): get_data('tests/echo.cwl')]), 0) def test_bool(self): - with NamedTemporaryFile() as f: + with NamedTemporaryFile(mode='w') as f: f.write(self.script2) f.flush() try: @@ -83,7 +84,7 @@ def test_bool(self): self.assertEquals(e.code, 0) def test_record_help(self): - with NamedTemporaryFile() as f: + with NamedTemporaryFile(mode='w') as f: f.write(self.script3) f.flush() try: @@ -92,7 +93,7 @@ def test_record_help(self): self.assertEquals(e.code, 0) def test_record(self): - with NamedTemporaryFile() as f: + with NamedTemporaryFile(mode='w') as f: f.write(self.script3) f.flush() try: diff --git a/tests/util.py b/tests/util.py index 8bad5157b..a9251ccbf 100644 --- a/tests/util.py +++ b/tests/util.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import import os from pkg_resources import (Requirement, ResolutionError, # type: ignore diff --git a/tox.ini b/tox.ini index d42c660c3..bbb101d60 100644 --- a/tox.ini +++ b/tox.ini @@ -1,53 +1,29 @@ [tox] -#envlist = py27-lint, py27-unit, py27-pipconflictchecker, py33-lint, py33-unit, py34-lint, py34-unit, py35-py2_mypy, py35-mypy, py35-lint, py35-unit, py36-lint, py36-unit # only when py3 compat is done -envlist = py27-lint, py27-unit, py27-pipconflictchecker, py36-lint, py35-lint, py34-lint, py33-lint, py35-py2_mypy +envlist = py27-lint, py27-unit, py27-pipconflictchecker, py36-lint, py35-lint, py34-lint, py33-lint, py35-mypy2 skipsdist = True [travis] python = 2.7: py27 - 3.5: py35-py2_mypy + 3.5: py35-mypy2 [testenv] deps = -rrequirements.txt -[testenv:py35-py2_mypy] -commands = make mypy +[testenv:py35-mypy2] +commands = make mypy2 whitelist_externals = make deps = - mypy==0.470 - typed-ast==0.6.3 + mypy==0.511 -rrequirements.txt -[testenv:py35-mypy] +[testenv:py35-mypy3] commands = make mypy3 whitelist_externals = make deps = - mypy==0.470 - typed-ast==0.6.3 + mypy==0.511 -rrequirements.txt - -[testenv:py36-lint] -commands = flake8 cwltool setup.py -whitelist_externals = flake8 -deps = flake8 - -[testenv:py35-lint] -commands = flake8 cwltool setup.py -whitelist_externals = flake8 -deps = flake8 - -[testenv:py34-lint] -commands = flake8 cwltool setup.py -whitelist_externals = flake8 -deps = flake8 - -[testenv:py33-lint] -commands = flake8 cwltool setup.py -whitelist_externals = flake8 -deps = flake8 - [testenv:py27-lint] commands = flake8 cwltool setup.py whitelist_externals = flake8 @@ -58,14 +34,5 @@ commands = pipconflictchecker whitelist_externals = pipconflictchecker deps = pip-conflict-checker -[testenv:py35-unit] -commands = python setup.py test - -[testenv:py34-unit] -commands = python setup.py test - -[testenv:py33-unit] -commands = python setup.py test - [testenv:py27-unit] commands = python setup.py test diff --git a/typeshed/2.7/StringIO.pyi b/typeshed/2.7/StringIO.pyi deleted file mode 100644 index 05c2ed8ee..000000000 --- a/typeshed/2.7/StringIO.pyi +++ /dev/null @@ -1,30 +0,0 @@ -# Stubs for StringIO (Python 2) - -from typing import (Any, IO, AnyStr, Iterator, Iterable, Generic, List, Text, - Union) - -class StringIO(IO[AnyStr], Generic[AnyStr]): - closed = ... # type: bool - softspace = ... # type: int - len = ... # type: int - def __init__(self, buf: AnyStr = ...) -> None: ... - def __iter__(self) -> Iterator[AnyStr]: ... - def next(self) -> AnyStr: ... - def close(self) -> None: ... - def isatty(self) -> bool: ... - def seek(self, pos: int, mode: int = ...) -> None: ... - def tell(self) -> int: ... - def read(self, n: int = ...) -> AnyStr: ... - def readline(self, length: int = ...) -> AnyStr: ... - def readlines(self, sizehint: int = ...) -> List[AnyStr]: ... - def truncate(self, size: int = ...) -> int: ... - def write(self, s: Union[str, Text]) -> None: ... - def writelines(self, iterable: Iterable[AnyStr]) -> None: ... - def flush(self) -> None: ... - def getvalue(self) -> AnyStr: ... - def __enter__(self) -> Any: ... - def __exit__(self, type: Any, value: Any, traceback: Any) -> Any: ... - def fileno(self) -> int: ... - def readable(self) -> bool: ... - def seekable(self) -> bool: ... - def writable(self) -> bool: ... diff --git a/typeshed/2.7/__builtin__.pyi b/typeshed/2.7/__builtin__.pyi deleted file mode 100644 index f6434b761..000000000 --- a/typeshed/2.7/__builtin__.pyi +++ /dev/null @@ -1,938 +0,0 @@ -# Stubs for builtins (Python 2.7) - -# True and False are deliberately omitted because they are keywords in -# Python 3, and stub files conform to Python 3 syntax. - -from typing import ( - TypeVar, Iterator, Iterable, overload, - Sequence, Mapping, Tuple, List, Any, Dict, Callable, Generic, Set, - AbstractSet, Sized, Reversible, SupportsInt, SupportsFloat, SupportsAbs, - SupportsRound, IO, BinaryIO, Union, AnyStr, MutableSequence, MutableMapping, - MutableSet, ItemsView, KeysView, ValuesView, Optional, Container, -) -from abc import abstractmethod, ABCMeta - -_T = TypeVar('_T') -_T_co = TypeVar('_T_co', covariant=True) -_KT = TypeVar('_KT') -_VT = TypeVar('_VT') -_S = TypeVar('_S') -_T1 = TypeVar('_T1') -_T2 = TypeVar('_T2') -_T3 = TypeVar('_T3') -_T4 = TypeVar('_T4') - -staticmethod = object() # Special, only valid as a decorator. -classmethod = object() # Special, only valid as a decorator. - -class object: - __doc__ = ... # type: str - __class__ = ... # type: type - - def __init__(self) -> None: ... - def __new__(cls) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - def __eq__(self, o: object) -> bool: ... - def __ne__(self, o: object) -> bool: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... - def __hash__(self) -> int: ... - -class type: - __bases__ = ... # type: Tuple[type, ...] - __name__ = ... # type: str - __module__ = ... # type: str - __dict__ = ... # type: Dict[unicode, Any] - - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, name: str, bases: Tuple[type, ...], dict: Dict[str, Any]) -> None: ... - # TODO: __new__ may have to be special and not a static method. - @overload - def __new__(cls, o: object) -> type: ... - @overload - def __new__(cls, name: str, bases: Tuple[type, ...], namespace: Dict[str, Any]) -> type: ... - def __call__(self, *args: Any, **kwds: Any) -> Any: ... - - # Only new-style classes - __mro__ = ... # type: Tuple[type, ...] - # Note: the documentation doesnt specify what the return type is, the standard - # implementation seems to be returning a list. - def mro(self) -> List[type]: ... - def __subclasses__(self) -> List[type]: ... - -class int(SupportsInt, SupportsFloat, SupportsAbs[int]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, x: SupportsInt) -> None: ... - @overload - def __init__(self, x: Union[str, unicode, bytearray], base: int = 10) -> None: ... - def bit_length(self) -> int: ... - - def __add__(self, x: int) -> int: ... - def __sub__(self, x: int) -> int: ... - def __mul__(self, x: int) -> int: ... - def __floordiv__(self, x: int) -> int: ... - def __div__(self, x: int) -> int: ... - def __truediv__(self, x: int) -> float: ... - def __mod__(self, x: int) -> int: ... - def __radd__(self, x: int) -> int: ... - def __rsub__(self, x: int) -> int: ... - def __rmul__(self, x: int) -> int: ... - def __rfloordiv__(self, x: int) -> int: ... - def __rdiv__(self, x: int) -> int: ... - def __rtruediv__(self, x: int) -> float: ... - def __rmod__(self, x: int) -> int: ... - def __pow__(self, x: int) -> Any: ... # Return type can be int or float, depending on x. - def __rpow__(self, x: int) -> Any: ... - def __and__(self, n: int) -> int: ... - def __or__(self, n: int) -> int: ... - def __xor__(self, n: int) -> int: ... - def __lshift__(self, n: int) -> int: ... - def __rshift__(self, n: int) -> int: ... - def __rand__(self, n: int) -> int: ... - def __ror__(self, n: int) -> int: ... - def __rxor__(self, n: int) -> int: ... - def __rlshift__(self, n: int) -> int: ... - def __rrshift__(self, n: int) -> int: ... - def __neg__(self) -> int: ... - def __pos__(self) -> int: ... - def __invert__(self) -> int: ... - - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: int) -> bool: ... - def __le__(self, x: int) -> bool: ... - def __gt__(self, x: int) -> bool: ... - def __ge__(self, x: int) -> bool: ... - - def __str__(self) -> str: ... - def __float__(self) -> float: ... - def __int__(self) -> int: ... - def __abs__(self) -> int: ... - def __hash__(self) -> int: ... - -class float(SupportsFloat, SupportsInt, SupportsAbs[float]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, x: SupportsFloat) -> None: ... - @overload - def __init__(self, x: unicode) -> None: ... - @overload - def __init__(self, x: bytearray) -> None: ... - def as_integer_ratio(self) -> Tuple[int, int]: ... - def hex(self) -> str: ... - def is_integer(self) -> bool: ... - @classmethod - def fromhex(cls, s: str) -> float: ... - - def __add__(self, x: float) -> float: ... - def __sub__(self, x: float) -> float: ... - def __mul__(self, x: float) -> float: ... - def __floordiv__(self, x: float) -> float: ... - def __div__(self, x: float) -> float: ... - def __truediv__(self, x: float) -> float: ... - def __mod__(self, x: float) -> float: ... - def __pow__(self, x: float) -> float: ... - def __radd__(self, x: float) -> float: ... - def __rsub__(self, x: float) -> float: ... - def __rmul__(self, x: float) -> float: ... - def __rfloordiv__(self, x: float) -> float: ... - def __rdiv__(self, x: float) -> float: ... - def __rtruediv__(self, x: float) -> float: ... - def __rmod__(self, x: float) -> float: ... - def __rpow__(self, x: float) -> float: ... - - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: float) -> bool: ... - def __le__(self, x: float) -> bool: ... - def __gt__(self, x: float) -> bool: ... - def __ge__(self, x: float) -> bool: ... - def __neg__(self) -> float: ... - def __pos__(self) -> float: ... - - def __str__(self) -> str: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - -class complex(SupportsAbs[float]): - @overload - def __init__(self, re: float = 0.0, im: float = 0.0) -> None: ... - @overload - def __init__(self, s: str) -> None: ... - - @property - def real(self) -> float: ... - @property - def imag(self) -> float: ... - - def conjugate(self) -> complex: ... - - def __add__(self, x: complex) -> complex: ... - def __sub__(self, x: complex) -> complex: ... - def __mul__(self, x: complex) -> complex: ... - def __pow__(self, x: complex) -> complex: ... - def __div__(self, x: complex) -> complex: ... - def __truediv__(self, x: complex) -> complex: ... - def __radd__(self, x: complex) -> complex: ... - def __rsub__(self, x: complex) -> complex: ... - def __rmul__(self, x: complex) -> complex: ... - def __rpow__(self, x: complex) -> complex: ... - def __rdiv__(self, x: complex) -> complex: ... - def __rtruediv__(self, x: complex) -> complex: ... - - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __neg__(self) -> complex: ... - def __pos__(self) -> complex: ... - - def __str__(self) -> str: ... - def __abs__(self) -> float: ... - def __hash__(self) -> int: ... - -class basestring(metaclass=ABCMeta): ... - -class unicode(basestring, Sequence[unicode]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, o: object) -> None: ... - @overload - def __init__(self, o: str, encoding: unicode = ..., errors: unicode = ...) -> None: ... - def capitalize(self) -> unicode: ... - def center(self, width: int, fillchar: unicode = u' ') -> unicode: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]], start: int = 0, - end: int = ...) -> bool: ... - def expandtabs(self, tabsize: int = 8) -> unicode: ... - def find(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def format(self, *args: Any, **kwargs: Any) -> unicode: ... - def format_map(self, map: Mapping[unicode, Any]) -> unicode: ... - def index(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdecimal(self) -> bool: ... - def isdigit(self) -> bool: ... - def isidentifier(self) -> bool: ... - def islower(self) -> bool: ... - def isnumeric(self) -> bool: ... - def isprintable(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, iterable: Iterable[unicode]) -> unicode: ... - def ljust(self, width: int, fillchar: unicode = u' ') -> unicode: ... - def lower(self) -> unicode: ... - def lstrip(self, chars: unicode = ...) -> unicode: ... - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: unicode, new: unicode, count: int = ...) -> unicode: ... - def rfind(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def rindex(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def rjust(self, width: int, fillchar: unicode = u' ') -> unicode: ... - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def rsplit(self, sep: unicode = ..., maxsplit: int = ...) -> List[unicode]: ... - def rstrip(self, chars: unicode = ...) -> unicode: ... - def split(self, sep: unicode = ..., maxsplit: int = ...) -> List[unicode]: ... - def splitlines(self, keepends: bool = ...) -> List[unicode]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]], start: int = 0, - end: int = ...) -> bool: ... - def strip(self, chars: unicode = ...) -> unicode: ... - def swapcase(self) -> unicode: ... - def title(self) -> unicode: ... - def translate(self, table: Union[Dict[int, Any], unicode]) -> unicode: ... - def upper(self) -> unicode: ... - def zfill(self, width: int) -> unicode: ... - - @overload - def __getitem__(self, i: int) -> unicode: ... - @overload - def __getitem__(self, s: slice) -> unicode: ... - def __getslice__(self, start: int, stop: int) -> unicode: ... - def __add__(self, s: unicode) -> unicode: ... - def __mul__(self, n: int) -> unicode: ... - def __mod__(self, x: Any) -> unicode: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... - - def __len__(self) -> int: ... - def __contains__(self, s: object) -> bool: ... - def __iter__(self) -> Iterator[unicode]: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __hash__(self) -> int: ... - -class str(basestring, Sequence[str]): - def __init__(self, object: object) -> None: ... - def capitalize(self) -> str: ... - def center(self, width: int, fillchar: str = ...) -> str: ... - def count(self, x: unicode) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> unicode: ... - def encode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... - def expandtabs(self, tabsize: int = 8) -> str: ... - def find(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def format(self, *args: Any, **kwargs: Any) -> str: ... - def index(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, iterable: Iterable[AnyStr]) -> AnyStr: ... - def ljust(self, width: int, fillchar: str = ...) -> str: ... - def lower(self) -> str: ... - @overload - def lstrip(self, chars: str = ...) -> str: ... - @overload - def lstrip(self, chars: unicode) -> unicode: ... - @overload - def partition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... - @overload - def partition(self, sep: str) -> Tuple[str, str, str]: ... - @overload - def partition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - def replace(self, old: AnyStr, new: AnyStr, count: int = ...) -> AnyStr: ... - def rfind(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def rindex(self, sub: unicode, start: int = 0, end: int = 0) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> str: ... - @overload - def rpartition(self, sep: bytearray) -> Tuple[str, bytearray, str]: ... - @overload - def rpartition(self, sep: str) -> Tuple[str, str, str]: ... - @overload - def rpartition(self, sep: unicode) -> Tuple[unicode, unicode, unicode]: ... - @overload - def rsplit(self, sep: str = ..., maxsplit: int = ...) -> List[str]: ... - @overload - def rsplit(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... - @overload - def rstrip(self, chars: str = ...) -> str: ... - @overload - def rstrip(self, chars: unicode) -> unicode: ... - @overload - def split(self, sep: str = ..., maxsplit: int = ...) -> List[str]: ... - @overload - def split(self, sep: unicode, maxsplit: int = ...) -> List[unicode]: ... - def splitlines(self, keepends: bool = ...) -> List[str]: ... - def startswith(self, prefix: Union[unicode, Tuple[unicode, ...]]) -> bool: ... - @overload - def strip(self, chars: str = ...) -> str: ... - @overload - def strip(self, chars: unicode) -> unicode: ... - def swapcase(self) -> str: ... - def title(self) -> str: ... - def translate(self, table: Optional[AnyStr], deletechars: AnyStr = ...) -> AnyStr: ... - def upper(self) -> str: ... - def zfill(self, width: int) -> str: ... - - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[str]: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __hash__(self) -> int: ... - @overload - def __getitem__(self, i: int) -> str: ... - @overload - def __getitem__(self, s: slice) -> str: ... - def __getslice__(self, start: int, stop: int) -> str: ... - def __add__(self, s: AnyStr) -> AnyStr: ... - def __mul__(self, n: int) -> str: ... - def __rmul__(self, n: int) -> str: ... - def __contains__(self, o: object) -> bool: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: unicode) -> bool: ... - def __le__(self, x: unicode) -> bool: ... - def __gt__(self, x: unicode) -> bool: ... - def __ge__(self, x: unicode) -> bool: ... - def __mod__(self, x: Any) -> str: ... - -class bytearray(MutableSequence[int]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, x: Union[Iterable[int], str]) -> None: ... - @overload - def __init__(self, x: unicode, encoding: unicode, - errors: unicode = ...) -> None: ... - @overload - def __init__(self, length: int) -> None: ... - def capitalize(self) -> bytearray: ... - def center(self, width: int, fillchar: str = ...) -> bytearray: ... - def count(self, x: str) -> int: ... - def decode(self, encoding: unicode = ..., errors: unicode = ...) -> str: ... - def endswith(self, suffix: Union[str, Tuple[str, ...]]) -> bool: ... - def expandtabs(self, tabsize: int = 8) -> bytearray: ... - def find(self, sub: str, start: int = 0, end: int = ...) -> int: ... - def index(self, sub: str, start: int = 0, end: int = ...) -> int: ... - def insert(self, index: int, object: int) -> None: ... - def isalnum(self) -> bool: ... - def isalpha(self) -> bool: ... - def isdigit(self) -> bool: ... - def islower(self) -> bool: ... - def isspace(self) -> bool: ... - def istitle(self) -> bool: ... - def isupper(self) -> bool: ... - def join(self, iterable: Iterable[str]) -> bytearray: ... - def ljust(self, width: int, fillchar: str = ...) -> bytearray: ... - def lower(self) -> bytearray: ... - def lstrip(self, chars: str = ...) -> bytearray: ... - def partition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def replace(self, old: str, new: str, count: int = ...) -> bytearray: ... - def rfind(self, sub: str, start: int = 0, end: int = ...) -> int: ... - def rindex(self, sub: str, start: int = 0, end: int = ...) -> int: ... - def rjust(self, width: int, fillchar: str = ...) -> bytearray: ... - def rpartition(self, sep: str) -> Tuple[bytearray, bytearray, bytearray]: ... - def rsplit(self, sep: str = ..., maxsplit: int = ...) -> List[bytearray]: ... - def rstrip(self, chars: str = ...) -> bytearray: ... - def split(self, sep: str = ..., maxsplit: int = ...) -> List[bytearray]: ... - def splitlines(self, keepends: bool = ...) -> List[bytearray]: ... - def startswith(self, prefix: Union[str, Tuple[str, ...]]) -> bool: ... - def strip(self, chars: str = ...) -> bytearray: ... - def swapcase(self) -> bytearray: ... - def title(self) -> bytearray: ... - def translate(self, table: str) -> bytearray: ... - def upper(self) -> bytearray: ... - def zfill(self, width: int) -> bytearray: ... - @staticmethod - def fromhex(x: str) -> bytearray: ... - - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __str__(self) -> str: ... - def __repr__(self) -> str: ... - def __int__(self) -> int: ... - def __float__(self) -> float: ... - def __hash__(self) -> int: ... - @overload - def __getitem__(self, i: int) -> int: ... - @overload - def __getitem__(self, s: slice) -> bytearray: ... - def __getslice__(self, start: int, stop: int) -> bytearray: ... - @overload - def __setitem__(self, i: int, x: int) -> None: ... - @overload - def __setitem__(self, s: slice, x: Union[Iterable[int], str]) -> None: ... - def __setslice__(self, start: int, stop: int, x: Union[Sequence[int], str]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... - def __delslice__(self, start: int, stop: int) -> None: ... - def __add__(self, s: str) -> bytearray: ... - def __mul__(self, n: int) -> bytearray: ... - def __contains__(self, o: object) -> bool: ... - def __eq__(self, x: object) -> bool: ... - def __ne__(self, x: object) -> bool: ... - def __lt__(self, x: str) -> bool: ... - def __le__(self, x: str) -> bool: ... - def __gt__(self, x: str) -> bool: ... - def __ge__(self, x: str) -> bool: ... - -class bool(int, SupportsInt, SupportsFloat): - def __init__(self, o: object = ...) -> None: ... - -class slice: - start = 0 - step = 0 - stop = 0 - def __init__(self, start: int, stop: int = 0, step: int = 0) -> None: ... - -class tuple(Sequence[_T_co], Generic[_T_co]): - def __init__(self, iterable: Iterable[_T_co] = ...) -> None: ... - def __len__(self) -> int: ... - def __contains__(self, x: object) -> bool: ... - @overload - def __getitem__(self, x: int) -> _T_co: ... - @overload - def __getitem__(self, x: slice) -> Tuple[_T_co, ...]: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __lt__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __le__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __gt__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __ge__(self, x: Tuple[_T_co, ...]) -> bool: ... - def __add__(self, x: Tuple[_T_co, ...]) -> Tuple[_T_co, ...]: ... - def __mul__(self, n: int) -> Tuple[_T_co, ...]: ... - def __rmul__(self, n: int) -> Tuple[_T_co, ...]: ... - def count(self, x: Any) -> int: ... - def index(self, x: Any) -> int: ... - -class function: - # TODO name of the class (corresponds to Python 'function' class) - __name__ = ... # type: str - __module__ = ... # type: str - -class list(MutableSequence[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T]) -> None: ... - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def pop(self, index: int = -1) -> _T: ... - def index(self, object: _T, start: int = 0, stop: int = ...) -> int: ... - def count(self, object: _T) -> int: ... - def insert(self, index: int, object: _T) -> None: ... - def remove(self, object: _T) -> None: ... - def reverse(self) -> None: ... - def sort(self, cmp: Callable[[_T, _T], Any] = ..., key: Callable[[_T], Any] = ..., reverse: bool = ...) -> None: ... - - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[_T]: ... - def __str__(self) -> str: ... - def __hash__(self) -> int: ... - @overload - def __getitem__(self, i: int) -> _T: ... - @overload - def __getitem__(self, s: slice) -> List[_T]: ... - def __getslice__(self, start: int, stop: int) -> List[_T]: ... - @overload - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - def __setslice__(self, start: int, stop: int, o: Sequence[_T]) -> None: ... - def __delitem__(self, i: Union[int, slice]) -> None: ... - def __delslice(self, start: int, stop: int) -> None: ... - def __add__(self, x: List[_T]) -> List[_T]: ... - def __iadd__(self, x: Iterable[_T]) -> List[_T]: ... - def __mul__(self, n: int) -> List[_T]: ... - def __rmul__(self, n: int) -> List[_T]: ... - def __contains__(self, o: object) -> bool: ... - def __reversed__(self) -> Iterator[_T]: ... - def __gt__(self, x: List[_T]) -> bool: ... - def __ge__(self, x: List[_T]) -> bool: ... - def __lt__(self, x: List[_T]) -> bool: ... - def __le__(self, x: List[_T]) -> bool: ... - -class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]): - # NOTE: Keyword arguments are special. If they are used, _KT must include - # str, but we have no way of enforcing it here. - @overload - def __init__(self, **kwargs: _VT) -> None: ... - @overload - def __init__(self, map: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def __init__(self, iterable: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - - def has_key(self, k: _KT) -> bool: ... - def clear(self) -> None: ... - def copy(self) -> Dict[_KT, _VT]: ... - def get(self, k: _KT, default: _VT = None) -> _VT: ... - def pop(self, k: _KT, default: _VT = ...) -> _VT: ... - def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... - @overload - def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - def keys(self) -> List[_KT]: ... - def values(self) -> List[_VT]: ... - def items(self) -> List[Tuple[_KT, _VT]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... - def viewkeys(self) -> KeysView[_KT]: ... - def viewvalues(self) -> ValuesView[_VT]: ... - def viewitems(self) -> ItemsView[_KT, _VT]: ... - @staticmethod - @overload - def fromkeys(seq: Sequence[_T]) -> Dict[_T, Any]: ... # TODO: Actually a class method - @staticmethod - @overload - def fromkeys(seq: Sequence[_T], value: _S) -> Dict[_T, _S]: ... - def __len__(self) -> int: ... - def __getitem__(self, k: _KT) -> _VT: ... - def __setitem__(self, k: _KT, v: _VT) -> None: ... - def __delitem__(self, v: _KT) -> None: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_KT]: ... - def __str__(self) -> str: ... - -class set(MutableSet[_T], Generic[_T]): - def __init__(self, iterable: Iterable[_T] = ...) -> None: ... - def add(self, element: _T) -> None: ... - def clear(self) -> None: ... - def copy(self) -> set[_T]: ... - def difference(self, *s: Iterable[Any]) -> set[_T]: ... - def difference_update(self, *s: Iterable[Any]) -> None: ... - def discard(self, element: _T) -> None: ... - def intersection(self, *s: Iterable[Any]) -> set[_T]: ... - def intersection_update(self, *s: Iterable[Any]) -> None: ... - def isdisjoint(self, s: Iterable[Any]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... - def pop(self) -> _T: ... - def remove(self, element: _T) -> None: ... - def symmetric_difference(self, s: Iterable[_T]) -> set[_T]: ... - def symmetric_difference_update(self, s: Iterable[_T]) -> None: ... - def union(self, *s: Iterable[_T]) -> set[_T]: ... - def update(self, *s: Iterable[_T]) -> None: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T]: ... - def __str__(self) -> str: ... - def __and__(self, s: AbstractSet[Any]) -> set[_T]: ... - def __iand__(self, s: AbstractSet[Any]) -> set[_T]: ... - def __or__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ... - def __ior__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ... - def __sub__(self, s: AbstractSet[Any]) -> set[_T]: ... - def __isub__(self, s: AbstractSet[Any]) -> set[_T]: ... - def __xor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ... - def __ixor__(self, s: AbstractSet[_S]) -> set[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... - # TODO more set operations - -class frozenset(AbstractSet[_T], Generic[_T]): - @overload - def __init__(self) -> None: ... - @overload - def __init__(self, iterable: Iterable[_T]) -> None: ... - def copy(self) -> frozenset[_T]: ... - def difference(self, *s: Iterable[Any]) -> frozenset[_T]: ... - def intersection(self, *s: Iterable[Any]) -> frozenset[_T]: ... - def isdisjoint(self, s: Iterable[_T]) -> bool: ... - def issubset(self, s: Iterable[Any]) -> bool: ... - def issuperset(self, s: Iterable[Any]) -> bool: ... - def symmetric_difference(self, s: Iterable[_T]) -> frozenset[_T]: ... - def union(self, *s: Iterable[_T]) -> frozenset[_T]: ... - def __len__(self) -> int: ... - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_T]: ... - def __str__(self) -> str: ... - def __and__(self, s: AbstractSet[_T]) -> frozenset[_T]: ... - def __or__(self, s: AbstractSet[_S]) -> frozenset[Union[_T, _S]]: ... - def __sub__(self, s: AbstractSet[_T]) -> frozenset[_T]: ... - def __xor__(self, s: AbstractSet[_S]) -> frozenset[Union[_T, _S]]: ... - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... - -class enumerate(Iterator[Tuple[int, _T]], Generic[_T]): - def __init__(self, iterable: Iterable[_T], start: int = 0) -> None: ... - def __iter__(self) -> Iterator[Tuple[int, _T]]: ... - def next(self) -> Tuple[int, _T]: ... - # TODO __getattribute__ - -class xrange(Sized, Iterable[int], Reversible[int]): - @overload - def __init__(self, stop: int) -> None: ... - @overload - def __init__(self, start: int, stop: int, step: int = 1) -> None: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[int]: ... - def __getitem__(self, i: int) -> int: ... - def __reversed__(self) -> Iterator[int]: ... - -class module: - __name__ = ... # type: str - __file__ = ... # type: str - __dict__ = ... # type: Dict[unicode, Any] - -class property: - def __init__(self, fget: Callable[[Any], Any] = None, - fset: Callable[[Any, Any], None] = None, - fdel: Callable[[Any], None] = None, doc: str = None) -> None: ... - def getter(self, fget: Callable[[Any], Any]) -> property: ... - def setter(self, fset: Callable[[Any, Any], None]) -> property: ... - def deleter(self, fdel: Callable[[Any], None]) -> property: ... - def __get__(self, obj: Any, type: type=None) -> Any: ... - def __set__(self, obj: Any, value: Any) -> None: ... - def __delete__(self, obj: Any) -> None: ... - -long = int -bytes = str - -NotImplemented = ... # type: Any - -def abs(n: SupportsAbs[_T]) -> _T: ... -def all(i: Iterable) -> bool: ... -def any(i: Iterable) -> bool: ... -def bin(number: int) -> str: ... -def callable(o: object) -> bool: ... -def chr(code: int) -> str: ... -def compile(source: Any, filename: unicode, mode: str, flags: int = 0, - dont_inherit: int = 0) -> Any: ... -def delattr(o: Any, name: unicode) -> None: ... -def dir(o: object = ...) -> List[str]: ... -@overload -def divmod(a: int, b: int) -> Tuple[int, int]: ... -@overload -def divmod(a: float, b: float) -> Tuple[float, float]: ... -def exit(code: int = ...) -> None: ... -def filter(function: Callable[[_T], Any], - iterable: Iterable[_T]) -> List[_T]: ... -def format(o: object, format_spec: str = '') -> str: ... # TODO unicode -def getattr(o: Any, name: unicode, default: Any = None) -> Any: ... -def hasattr(o: Any, name: unicode) -> bool: ... -def hash(o: object) -> int: ... -def hex(i: int) -> str: ... # TODO __index__ -def id(o: object) -> int: ... -def input(prompt: unicode = ...) -> Any: ... -def intern(string: str) -> str: ... -@overload -def iter(iterable: Iterable[_T]) -> Iterator[_T]: ... -@overload -def iter(function: Callable[[], _T], sentinel: _T) -> Iterator[_T]: ... -def isinstance(o: object, t: Union[type, Tuple[type, ...]]) -> bool: ... -def issubclass(cls: type, classinfo: Union[type, Tuple[type, ...]]) -> bool: ... -def len(o: Sized) -> int: ... -@overload -def map(func: Callable[[_T1], _S], iter1: Iterable[_T1]) -> List[_S]: ... -@overload -def map(func: Callable[[_T1, _T2], _S], - iter1: Iterable[_T1], - iter2: Iterable[_T2]) -> List[_S]: ... # TODO more than two iterables -@overload -def max(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def max(iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(arg1: _T, arg2: _T, *args: _T, key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def min(iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> _T: ... -@overload -def next(i: Iterator[_T]) -> _T: ... -@overload -def next(i: Iterator[_T], default: _T) -> _T: ... -def oct(i: int) -> str: ... # TODO __index__ -@overload -def open(file: str, mode: AnyStr = 'r', buffering: int = ...) -> BinaryIO: ... -@overload -def open(file: unicode, mode: AnyStr = 'r', buffering: int = ...) -> BinaryIO: ... -@overload -def open(file: int, mode: str = 'r', buffering: int = ...) -> BinaryIO: ... -def ord(c: unicode) -> int: ... -# This is only available after from __future__ import print_function. -def print(*values: Any, sep: unicode = u' ', end: unicode = u'\n', - file: IO[Any] = ...) -> None: ... -@overload -def pow(x: int, y: int) -> Any: ... # The return type can be int or float, depending on y. -@overload -def pow(x: int, y: int, z: int) -> Any: ... -@overload -def pow(x: float, y: float) -> float: ... -@overload -def pow(x: float, y: float, z: float) -> float: ... -def quit(code: int = ...) -> None: ... -def range(x: int, y: int = 0, step: int = 1) -> List[int]: ... -def raw_input(prompt: unicode = ...) -> str: ... - -@overload -def reduce(function: Callable[[_T, _S], _T], iterable: Iterable[_S], initializer: _T) -> _T: ... -@overload -def reduce(function: Callable[[_T, _T], _T], iterable: Iterable[_T]) -> _T: ... - -def reload(module: Any) -> Any: ... -@overload -def reversed(object: Reversible[_T]) -> Iterator[_T]: ... -@overload -def reversed(object: Sequence[_T]) -> Iterator[_T]: ... -def repr(o: object) -> str: ... -@overload -def round(number: float) -> float: ... -@overload -def round(number: float, ndigits: int) -> float: ... # Always return a float if given ndigits. -@overload -def round(number: SupportsRound[_T]) -> _T: ... -@overload -def round(number: SupportsRound[_T], ndigits: int) -> _T: ... -def setattr(object: Any, name: unicode, value: Any) -> None: ... -def sorted(iterable: Iterable[_T], *, - cmp: Callable[[_T, _T], int] = ..., - key: Callable[[_T], Any] = ..., - reverse: bool = ...) -> List[_T]: ... -def sum(iterable: Iterable[_T], start: _T = ...) -> _T: ... -def unichr(i: int) -> unicode: ... -def vars(object: Any = ...) -> Dict[str, Any]: ... -@overload -def zip(iter1: Iterable[_T1]) -> List[Tuple[_T1]]: ... -@overload -def zip(iter1: Iterable[_T1], - iter2: Iterable[_T2]) -> List[Tuple[_T1, _T2]]: ... -@overload -def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], - iter3: Iterable[_T3]) -> List[Tuple[_T1, _T2, _T3]]: ... -@overload -def zip(iter1: Iterable[_T1], iter2: Iterable[_T2], iter3: Iterable[_T3], - iter4: Iterable[_T4]) -> List[Tuple[_T1, _T2, - _T3, _T4]]: ... # TODO more than four iterables -def __import__(name: unicode, - globals: Dict[str, Any] = ..., - locals: Dict[str, Any] = ..., - fromlist: List[str] = ..., level: int = ...) -> Any: ... - -def globals() -> Dict[str, Any]: ... -def locals() -> Dict[str, Any]: ... - -# Actually the type of Ellipsis is , but since it's -# not exposed anywhere under that name, we make it private here. -class ellipsis: ... -Ellipsis = ... # type: ellipsis - -# TODO: buffer support is incomplete; e.g. some_string.startswith(some_buffer) doesn't type check. -AnyBuffer = TypeVar('AnyBuffer', str, unicode, bytearray, buffer) - -class buffer(Sized): - def __init__(self, object: AnyBuffer, offset: int = ..., size: int = ...) -> None: ... - def __add__(self, other: AnyBuffer) -> str: ... - def __cmp__(self, other: AnyBuffer) -> bool: ... - def __getitem__(self, key: Union[int, slice]) -> str: ... - def __getslice__(self, i: int, j: int) -> str: ... - def __len__(self) -> int: ... - def __mul__(self, x: int) -> str: ... - -class memoryview(Sized, Container[bytes]): - format = ... # type: str - itemsize = ... # type: int - shape = ... # type: Optional[Tuple[int, ...]] - strides = ... # type: Optional[Tuple[int, ...]] - suboffsets = ... # type: Optional[Tuple[int, ...]] - readonly = ... # type: bool - ndim = ... # type: int - - def __init__(self, obj: Union[str, bytearray, buffer, memoryview]) -> None: ... - - @overload - def __getitem__(self, i: int) -> bytes: ... - @overload - def __getitem__(self, s: slice) -> memoryview: ... - - def __contains__(self, x: object) -> bool: ... - def __iter__(self) -> Iterator[bytes]: ... - def __len__(self) -> int: ... - - @overload - def __setitem__(self, i: int, o: bytes) -> None: ... - @overload - def __setitem__(self, s: slice, o: Sequence[bytes]) -> None: ... - @overload - def __setitem__(self, s: slice, o: memoryview) -> None: ... - - def tobytes(self) -> bytes: ... - def tolist(self) -> List[int]: ... - -class BaseException: - args = ... # type: Any - message = ... # type: str - def __init__(self, *args: Any) -> None: ... - def with_traceback(self, tb: Any) -> BaseException: ... -class GeneratorExit(BaseException): ... -class KeyboardInterrupt(BaseException): ... -class SystemExit(BaseException): - code = 0 -class Exception(BaseException): ... -class StopIteration(Exception): ... -class StandardError(Exception): ... -class ArithmeticError(StandardError): ... -class BufferError(StandardError): ... -class EnvironmentError(StandardError): - errno = 0 - strerror = ... # type: str - # TODO can this be unicode? - filename = ... # type: str -class LookupError(StandardError): ... -class RuntimeError(StandardError): ... -class ValueError(StandardError): ... -class AssertionError(StandardError): ... -class AttributeError(StandardError): ... -class EOFError(StandardError): ... -class FloatingPointError(ArithmeticError): ... -class IOError(EnvironmentError): ... -class ImportError(StandardError): ... -class IndexError(LookupError): ... -class KeyError(LookupError): ... -class MemoryError(StandardError): ... -class NameError(StandardError): ... -class NotImplementedError(RuntimeError): ... -class OSError(EnvironmentError): ... -class WindowsError(OSError): - winerror = ... # type: int -class OverflowError(ArithmeticError): ... -class ReferenceError(StandardError): ... -class SyntaxError(StandardError): - msg = ... # type: str - lineno = ... # type: int - offset = ... # type: int - text = ... # type: str -class IndentationError(SyntaxError): ... -class TabError(IndentationError): ... -class SystemError(StandardError): ... -class TypeError(StandardError): ... -class UnboundLocalError(NameError): ... -class UnicodeError(ValueError): ... -class UnicodeDecodeError(UnicodeError): ... -class UnicodeEncodeError(UnicodeError): ... -class UnicodeTranslateError(UnicodeError): ... -class ZeroDivisionError(ArithmeticError): ... - -class Warning(Exception): ... -class UserWarning(Warning): ... -class DeprecationWarning(Warning): ... -class SyntaxWarning(Warning): ... -class RuntimeWarning(Warning): ... -class FutureWarning(Warning): ... -class PendingDeprecationWarning(Warning): ... -class ImportWarning(Warning): ... -class UnicodeWarning(Warning): ... -class BytesWarning(Warning): ... -class ResourceWarning(Warning): ... - -def eval(s: str, globals: Dict[str, Any] = ..., locals: Dict[str, Any] = ...) -> Any: ... -def exec(object: str, - globals: Dict[str, Any] = None, - locals: Dict[str, Any] = None) -> Any: ... # TODO code object as source - -def cmp(x: Any, y: Any) -> int: ... - -def execfile(filename: str, globals: Dict[str, Any] = None, locals: Dict[str, Any] = None) -> None: ... - -class file(BinaryIO): - @overload - def __init__(self, file: str, mode: str = 'r', buffering: int = ...) -> None: ... - @overload - def __init__(self, file: unicode, mode: str = 'r', buffering: int = ...) -> None: ... - @overload - def __init__(self, file: int, mode: str = 'r', buffering: int = ...) -> None: ... - def __iter__(self) -> Iterator[str]: ... - def read(self, n: int = ...) -> str: ... - def __enter__(self) -> BinaryIO: ... - def __exit__(self, t: type = None, exc: BaseException = None, tb: Any = None) -> bool: ... - def flush(self) -> None: ... - def fileno(self) -> int: ... - def isatty(self) -> bool: ... - def close(self) -> None: ... - - def readable(self) -> bool: ... - def writable(self) -> bool: ... - def seekable(self) -> bool: ... - def seek(self, offset: int, whence: int = ...) -> None: ... - def tell(self) -> int: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def write(self, data: AnyStr) -> None: ... - def writelines(self, data: Iterable[str]) -> None: ... - def truncate(self, pos: int = ...) -> int: ... - -# Very old builtins -def apply(func: Callable[..., _T], args: Sequence[Any] = None, kwds: Mapping[str, Any] = None) -> _T: ... -_N = TypeVar('_N', bool, int, float, complex) -def coerce(x: _N, y: _N) -> Tuple[_N, _N]: ... diff --git a/typeshed/2.7/argparse.pyi b/typeshed/2.7/argparse.pyi deleted file mode 100644 index e35f17ff9..000000000 --- a/typeshed/2.7/argparse.pyi +++ /dev/null @@ -1,162 +0,0 @@ -# Stubs for argparse (Python 3.4) - -from typing import ( - Any, AnyStr, Callable, Iterable, List, IO, Optional, Sequence, Text, Tuple, - Type, Union, TypeVar, overload -) -import sys - -_T = TypeVar('_T') - - -ONE_OR_MORE = ... # type: str -OPTIONAL = ... # type: str -PARSER = ... # type: str -REMAINDER = ... # type: str -SUPPRESS = ... # type: str -ZERO_OR_MORE = ... # type: str - -class ArgumentError(Exception): ... - -class ArgumentParser: - if sys.version_info >= (3, 5): - def __init__(self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: Type[HelpFormatter] = ..., - prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., - argument_default: Optional[str] = ..., - conflict_handler: str = ..., - add_help: bool = ..., - allow_abbrev: bool = ...) -> None: ... - else: - def __init__(self, - prog: Optional[str] = ..., - usage: Optional[str] = ..., - description: Optional[str] = ..., - epilog: Optional[str] = ..., - parents: Sequence[ArgumentParser] = ..., - formatter_class: Type[HelpFormatter] = ..., - prefix_chars: str = ..., - fromfile_prefix_chars: Optional[str] = ..., - argument_default: Optional[str] = ..., - conflict_handler: str = ..., - add_help: bool = ...) -> None: ... - def add_argument(self, - *name_or_flags: Union[str, Sequence[str]], - action: Union[str, Type[Action]] = ..., - nargs: Union[int, str] = ..., - const: Any = ..., - default: Any = ..., - type: Union[Callable[[str], _T], FileType] = ..., - choices: Iterable[_T] = ..., - required: bool = ..., - help: str = ..., - metavar: Union[str, Tuple[str, ...]] = ..., - dest: str = ..., - version: str = ..., - **kwargs: Any) -> None: ... # weirdly documented - def parse_args(self, args: Optional[Sequence[str]] = ..., - namespace: Optional[Namespace] = ...) -> Namespace: ... - def add_subparsers(self, title: str = ..., - description: Optional[str] = ..., - prog: str = ..., - parser_class: Type[ArgumentParser] = ..., - action: Type[Action] = ..., - option_string: str = ..., - dest: Optional[str] = ..., - help: Optional[str] = ..., - metavar: Optional[str] = ...) -> _SubParsersAction: ... - def add_argument_group(self, title: Optional[Text] = ..., - description: Optional[Text] = ...) -> _ArgumentGroup: ... - def add_mutually_exclusive_group(self, required: bool = ...) -> _MutuallyExclusiveGroup: ... - def set_defaults(self, **kwargs: Any) -> None: ... - def get_default(self, dest: str) -> Any: ... - def print_usage(self, file: Optional[IO[str]] = ...) -> None: ... - def print_help(self, file: Optional[IO[str]] = ...) -> None: ... - def format_usage(self) -> str: ... - def format_help(self) -> str: ... - def parse_known_args(self, args: Optional[Sequence[str]] = ..., - namespace: Optional[Namespace] = ...) -> Tuple[Namespace, List[str]]: ... - def convert_arg_line_to_args(self, arg_line: str) -> List[str]: ... - def exit(self, status: int = ..., message: Optional[str] = ...) -> None: ... - def error(self, message: str) -> None: ... - -class HelpFormatter: - # not documented - def __init__(self, prog: str, indent_increment: int = ..., - max_help_position: int = ..., - width: Optional[int] = ...) -> None: ... -class RawDescriptionHelpFormatter(HelpFormatter): ... -class RawTextHelpFormatter(HelpFormatter): ... -class ArgumentDefaultsHelpFormatter(HelpFormatter): ... -if sys.version_info >= (3,): - class MetavarTypeHelpFormatter(HelpFormatter): ... - -class Action: - def __init__(self, - option_strings: Sequence[AnyStr], - dest: Union[str, Text] = ..., - nargs: Optional[Union[int, str]] = ..., - const: Any = ..., - default: Any = ..., - type: Union[Callable[[str], _T], FileType, None] = ..., - choices: Optional[Iterable[_T]] = ..., - required: bool = ..., - help: Optional[str] = ..., - metavar: Union[str, Tuple[str, ...]] = ...) -> None: - self.dest = dest - self.option_strings = option_strings - self.default = default - self.type = type - self.required = required - self.help = help - - def __call__(self, parser: ArgumentParser, namespace: Namespace, - values: Union[AnyStr, Sequence[Any], None], - option_string: AnyStr = ...) -> None: ... - -class Namespace: - def __getattr__(self, name: str) -> Any: ... - def __setattr__(self, name: str, value: Any) -> None: ... - -class FileType: - if sys.version_info >= (3, 4): - def __init__(self, mode: str = ..., bufsize: int = ..., - encoding: Optional[str] = ..., - errors: Optional[str] = ...) -> None: ... - elif sys.version_info >= (3,): - def __init__(self, - mode: str = ..., bufsize: int = ...) -> None: ... - else: - def __init__(self, - mode: str = ..., bufsize: Optional[int] = ...) -> None: ... - def __call__(self, string: str) -> IO[Any]: ... - -class _ArgumentGroup: - def add_argument(self, - *name_or_flags: Union[str, Sequence[str]], - action: Union[str, Type[Action]] = ..., - nargs: Union[int, str] = ..., - const: Any = ..., - default: Any = ..., - type: Union[Callable[[str], _T], FileType] = ..., - choices: Iterable[_T] = ..., - required: bool = ..., - help: str = ..., - metavar: Union[str, Tuple[str, ...]] = ..., - dest: str = ..., - version: str = ...) -> None: ... - -class _MutuallyExclusiveGroup(_ArgumentGroup): ... - -class _SubParsersAction: - # TODO: Type keyword args properly. - def add_parser(self, name: str, **kwargs: Any) -> ArgumentParser: ... - -# not documented -class ArgumentTypeError(Exception): ... diff --git a/typeshed/2.7/galaxy/tools/deps/__init__.pyi b/typeshed/2.7/galaxy/tools/deps/__init__.pyi index 2bf533cd6..1df97ad92 100644 --- a/typeshed/2.7/galaxy/tools/deps/__init__.pyi +++ b/typeshed/2.7/galaxy/tools/deps/__init__.pyi @@ -2,7 +2,7 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any, Optional +from typing import Any, Optional, List from .requirements import ToolRequirement as ToolRequirement, ToolRequirements as ToolRequirements from .resolvers import NullDependency as NullDependency from .resolvers.conda import CondaDependencyResolver as CondaDependencyResolver diff --git a/typeshed/2.7/io.pyi b/typeshed/2.7/io.pyi deleted file mode 100644 index 2020ef417..000000000 --- a/typeshed/2.7/io.pyi +++ /dev/null @@ -1,102 +0,0 @@ -# Stubs for io - -# Based on https://docs.python.org/2/library/io.html - -# Only a subset of functionality is included. - -DEFAULT_BUFFER_SIZE = 0 - -from typing import (AnyStr, List, BinaryIO, TextIO, IO, overload, Iterator, - Iterable, Any, Union) - -def open(file: Union[str, unicode, int], - mode: unicode = ..., buffering: int = ..., encoding: unicode = ..., - errors: unicode = ..., newline: unicode = ..., - closefd: bool = ...) -> IO[Any]: ... - -class IOBase: - # TODO - ... - -class BytesIO(BinaryIO): - def __init__(self, initial_bytes: str = ...) -> None: ... - # TODO getbuffer - # TODO see comments in BinaryIO for missing functionality - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> str: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> str: ... - def readlines(self, hint: int = ...) -> List[str]: ... - def seek(self, offset: int, whence: int = ...) -> None: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: AnyStr) -> None: ... - def writelines(self, lines: Iterable[str]) -> None: ... - def getvalue(self) -> str: ... - def read1(self) -> str: ... - - def __iter__(self) -> Iterator[str]: ... - def __enter__(self) -> 'BytesIO': ... - def __exit__(self, type, value, traceback) -> bool: ... - -class StringIO(TextIO): - def __init__(self, initial_value: unicode = ..., - newline: unicode = ...) -> None: ... - # TODO see comments in BinaryIO for missing functionality - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> unicode: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> unicode: ... - def readlines(self, hint: int = ...) -> List[unicode]: ... - def seek(self, offset: int, whence: int = ...) -> None: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: unicode) -> None: ... - def writelines(self, lines: Iterable[unicode]) -> None: ... - def getvalue(self) -> unicode: ... - - def __iter__(self) -> Iterator[unicode]: ... - def __enter__(self) -> 'StringIO': ... - def __exit__(self, type, value, traceback) -> bool: ... - -class TextIOWrapper(TextIO): - # write_through is undocumented but used by subprocess - def __init__(self, buffer: IO[str], encoding: unicode = ..., - errors: unicode = ..., newline: unicode = ..., - line_buffering: bool = ..., - write_through: bool = ...) -> None: ... - # TODO see comments in BinaryIO for missing functionality - def close(self) -> None: ... - def closed(self) -> bool: ... - def fileno(self) -> int: ... - def flush(self) -> None: ... - def isatty(self) -> bool: ... - def read(self, n: int = ...) -> unicode: ... - def readable(self) -> bool: ... - def readline(self, limit: int = ...) -> unicode: ... - def readlines(self, hint: int = ...) -> List[unicode]: ... - def seek(self, offset: int, whence: int = ...) -> None: ... - def seekable(self) -> bool: ... - def tell(self) -> int: ... - def truncate(self, size: int = ...) -> int: ... - def writable(self) -> bool: ... - def write(self, s: unicode) -> None: ... - def writelines(self, lines: Iterable[unicode]) -> None: ... - - def __iter__(self) -> Iterator[unicode]: ... - def __enter__(self) -> StringIO: ... - def __exit__(self, type, value, traceback) -> bool: ... - -class BufferedIOBase(IOBase): ... diff --git a/typeshed/2.7/logging/__init__.pyi b/typeshed/2.7/logging/__init__.pyi deleted file mode 100644 index d98386b12..000000000 --- a/typeshed/2.7/logging/__init__.pyi +++ /dev/null @@ -1,355 +0,0 @@ -## Stubs for logging (Python 3.4) - -from typing import ( - Any, Callable, Iterable, Mapping, MutableMapping, Optional, IO, Tuple, - Text, Union, - overload, -) -from types import TracebackType -import sys - -_SysExcInfoType = Union[Tuple[type, BaseException, TracebackType], - Tuple[None, None, None]] -if sys.version_info >= (3, 5): - _ExcInfoType = Union[bool, _SysExcInfoType, Exception] -else: - _ExcInfoType = Union[bool, _SysExcInfoType] -_ArgsType = Union[Tuple[Any, ...], Dict[str, Any]] -_FilterType = Union['Filter', Callable[[LogRecord], int]] - - -class Logger: - name = ... # type: str - level = ... # type: int - parent = ... # type: Union[Logger, PlaceHolder] - propagate = ... # type: bool - handlers = ... # type: List[Handler] - disabled = ... # type: int - def setLevel(self, lvl: Union[int, str]) -> None: ... - def isEnabledFor(self, lvl: int) -> Union[int, bool]: ... - def getEffectiveLevel(self) -> int: ... - def getChild(self, suffix: str) -> 'Logger': ... - if sys.version_info > (3,): - def debug(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def info(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def warning(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def warn(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def error(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def critical(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def log(self, lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def exception(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - else: - def debug(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def info(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def warning(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def warn(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def error(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def critical(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def log(self, - lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def exception(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def addFilter(self, filt: _FilterType) -> None: ... - def removeFilter(self, filt: _FilterType) -> None: ... - def filter(self, record: 'LogRecord') -> bool: ... - def addHandler(self, hdlr: 'Handler') -> None: ... - def removeHandler(self, hdlr: 'Handler') -> None: ... - if sys.version_info >= (3,): - def findCaller(self, stack_info: bool = ...) -> Tuple[str, int, str, Optional[str]]: ... - else: - def findCaller(self) -> Tuple[str, int, str]: ... - def handle(self, record: 'LogRecord') -> None: ... - if sys.version_info >= (3,): - def makeRecord(self, name: str, lvl: int, fn: str, lno: int, msg: Text, - args: Mapping[str, Any], - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - extra: Optional[Mapping[str, Any]] = ..., - sinfo: Optional[str] = ...) -> None: ... - else: - def makeRecord(self, - name: str, lvl: int, fn: str, lno: int, msg: Text, - args: Mapping[str, Any], - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - extra: Optional[Mapping[str, Any]] = ...) -> None: ... - if sys.version_info >= (3,): - def hasHandlers(self) -> bool: ... - - -CRITICAL = ... # type: int -ERROR = ... # type: int -WARNING = ... # type: int -WARN = ... # type: int -INFO = ... # type: int -DEBUG = ... # type: int -NOTSET = ... # type: int - - -class Handler: - def __init__(self, level: int = ...) -> None: ... - def createLock(self) -> None: ... - def acquire(self) -> None: ... - def release(self) -> None: ... - def setLevel(self, lvl: Union[int, str]) -> None: ... - def setFormatter(self, form: 'Formatter') -> None: ... - def addFilter(self, filt: _FilterType) -> None: ... - def removeFilter(self, filt: _FilterType) -> None: ... - def filter(self, record: 'LogRecord') -> bool: ... - def flush(self) -> None: ... - def close(self) -> None: ... - def handle(self, record: 'LogRecord') -> None: ... - def handleError(self, record: 'LogRecord') -> None: ... - def format(self, record: 'LogRecord') -> None: ... - def emit(self, record: 'LogRecord') -> None: ... - - -class Formatter: - if sys.version_info >= (3,): - def __init__(self, fmt: Optional[str] = ..., - datefmt: Optional[str] =..., - style: str = ...) -> None: ... - else: - def __init__(self, - fmt: Optional[str] = ..., - datefmt: Optional[str] =...) -> None: ... - def format(self, record: LogRecord) -> str: ... - def formatTime(self, record: LogRecord, datefmt: str = ...) -> str: ... - def formatException(self, exc_info: _SysExcInfoType) -> str: ... - if sys.version_info >= (3,): - def formatStack(self, stack_info: str) -> str: ... - - -class Filter: - def __init__(self, name: str = ...) -> None: ... - def filter(self, record: LogRecord) -> int: ... - - -class LogRecord: - args = ... # type: _ArgsType - asctime = ... # type: str - created = ... # type: int - exc_info = ... # type: Optional[_SysExcInfoType] - filename = ... # type: str - funcName = ... # type: str - levelname = ... # type: str - levelno = ... # type: int - lineno = ... # type: int - module = ... # type: str - msecs = ... # type: int - message = ... # type: str - msg = ... # type: str - name = ... # type: str - pathname = ... # type: str - process = ... # type: int - processName = ... # type: str - relativeCreated = ... # type: int - if sys.version_info >= (3,): - stack_info = ... # type: Optional[str] - thread = ... # type: int - threadName = ... # type: str - if sys.version_info >= (3,): - def __init__(self, name: str, level: int, pathname: str, lineno: int, - msg: Text, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ..., - sinfo: Optional[str] = ...) -> None: ... - else: - def __init__(self, - name: str, level: int, pathname: str, lineno: int, - msg: Text, args: _ArgsType, - exc_info: Optional[_SysExcInfoType], - func: Optional[str] = ...) -> None: ... - def getMessage(self) -> str: ... - - -class LoggerAdapter: - def __init__(self, logger: Logger, extra: Mapping[str, Any]) -> None: ... - def process(self, msg: Text, kwargs: MutableMapping[str, Any]) -> Tuple[str, MutableMapping[str, Any]]: ... - if sys.version_info > (3,): - def debug(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def info(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def warning(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def error(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def exception(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def critical(self, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def log(self, lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - else: - def debug(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def info(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def warning(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def error(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def exception(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def critical(self, - msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def log(self, - lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def isEnabledFor(self, lvl: int) -> Union[int, bool]: ... - if sys.version_info >= (3,): - def getEffectiveLevel(self) -> int: ... - def setLevel(self, lvl: Union[int, str]) -> None: ... - def hasHandlers(self) -> bool: ... - - -if sys.version_info >= (3,): - def getLogger(name: Optional[str] = ...) -> Logger: ... -else: - @overload - def getLogger() -> Logger: ... - @overload - def getLogger(name: str) -> Logger: ... -def getLoggerClass() -> type: ... -if sys.version_info >= (3,): - def getLogRecordFactory() -> Callable[..., LogRecord]: ... - -if sys.version_info > (3,): - def debug(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def info(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def warning(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def warn(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def error(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def critical(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def exception(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... - def log(lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - stack_info: bool = ..., extra: Dict[str, Any] = ..., - **kwargs: Any) -> None: ... -else: - def debug(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def info(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def warning(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def warn(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def error(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def critical(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def exception(msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - def log(lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ..., - extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ... - -def disable(lvl: int) -> None: ... -def addLevelName(lvl: int, levelName: str) -> None: ... -def getLevelName(lvl: int) -> str: ... - -def makeLogRecord(attrdict: Mapping[str, Any]) -> LogRecord: ... - -if sys.version_info >= (3,): - def basicConfig(*, filename: str = ..., filemode: str = ..., - format: str = ..., datefmt: str = ..., style: str = ..., - level: int = ..., stream: IO[str] = ..., - handlers: Iterable[Handler] = ...) -> None: ... -else: - @overload - def basicConfig() -> None: ... - @overload - def basicConfig(*, filename: str = ..., filemode: str = ..., - format: str = ..., datefmt: str = ..., - level: int = ..., stream: IO[str] = ...) -> None: ... -def shutdown() -> None: ... - -def setLoggerClass(klass: type) -> None: ... -if sys.version_info >= (3,): - def setLogRecordFactory(factory: Callable[..., LogRecord]) -> None: ... - - -if sys.version_info >= (3,): - lastResort = ... # type: Optional['StreamHandler'] - - -class StreamHandler(Handler): - def __init__(self, stream: Optional[IO[str]] = ...) -> None: ... - - -class FileHandler(Handler): - def __init__(self, filename: str, mode: str = ..., - encoding: Optional[str] = ..., delay: bool = ...) -> None: ... - - -class NullHandler(Handler): ... - - -class PlaceHolder: - def __init__(self, alogger: Logger) -> None: ... - def append(self, alogger: Logger) -> None: ... - - -# Below aren't in module docs but still visible - -class RootLogger(Logger): - pass - -root = ... # type: RootLogger diff --git a/typeshed/2.7/logging/config.pyi b/typeshed/2.7/logging/config.pyi deleted file mode 100644 index d4665d779..000000000 --- a/typeshed/2.7/logging/config.pyi +++ /dev/null @@ -1,25 +0,0 @@ -# Stubs for logging.config (Python 3.4) - -from typing import Any, Callable, Dict, Optional, IO, Union -import sys -if sys.version_info >= (3,): - #from configparser import RawConfigParser - # TODO add RawConfigParser to configparser stubs - RawConfigParser = Any -else: - from ConfigParser import RawConfigParser - - -def dictConfig(config: Dict[str, Any]) -> None: ... -if sys.version_info >= (3, 4): - def fileConfig(fname: Union[str, IO[str], RawConfigParser], - defaults: Optional[Dict[str, str]] = ..., - disable_existing_loggers: bool = ...) -> None: ... - def listen(port: int = ..., - verify: Optional[Callable[[bytes], Optional[bytes]]] = ...) -> None: ... -else: - def fileConfig(fname: Union[str, IO[str]], - defaults: Optional[Dict[str, str]] = ..., - disable_existing_loggers: bool = ...) -> None: ... - def listen(port: int = ...) -> None: ... -def stopListening() -> None: ... diff --git a/typeshed/2.7/logging/handlers.pyi b/typeshed/2.7/logging/handlers.pyi deleted file mode 100644 index 7aedcb2d8..000000000 --- a/typeshed/2.7/logging/handlers.pyi +++ /dev/null @@ -1,200 +0,0 @@ -## Stubs for logging.handlers (Python 2.4) - -from typing import Any, Callable, Optional, Tuple, Union, overload -from logging import Handler, FileHandler, LogRecord -import datetime -if sys.version_info >= (3,): - from queue import Queue -else: - from Queue import Queue -from socket import SocketType -# TODO update socket stubs to add SocketKind -SocketKind = int -import ssl -import sys - - -class WatchedFileHandler(Handler): - @overload - def __init__(self, filename: str) -> None: ... - @overload - def __init__(self, filename: str, mode: str) -> None: ... - @overload - def __init__(self, filename: str, mode: str, - encoding: Optional[str]) -> None: ... - @overload - def __init__(self, filename: str, mode: str, encoding: Optional[str], - delay: bool) -> None: ... - - -if sys.version_info >= (3,): - class BaseRotatingHandler(FileHandler): - namer = ... # type: Optional[Callable[[str], None]] - rotator = ... # type: Optional[Callable[[str, str], None]] - def __init__(self, filename: str, mode: str, - encoding: Optional[str] = ..., - delay: bool = ...) -> None: ... - def rotation_filename(self, default_name: str) -> None: ... - def rotate(self, source: str, dest: str) -> None: ... - - -if sys.version_info >= (3,): - class RotatingFileHandler(BaseRotatingHandler): - def __init__(self, filename: str, mode: str = ..., maxBytes: int = ..., - backupCount: int = ..., encoding: Optional[str] = ..., - delay: bool = ...) -> None: ... - def doRollover(self) -> None: ... -else: - class RotatingFileHandler(Handler): - def __init__(self, filename: str, mode: str = ..., maxBytes: int = ..., - backupCount: int = ..., encoding: Optional[str] = ..., - delay: bool = ...) -> None: ... - def doRollover(self) -> None: ... - - -if sys.version_info >= (3,): - class TimedRotatingFileHandler(BaseRotatingHandler): - if sys.version_info >= (3, 4): - def __init__(self, filename: str, when: str = ..., - interval: int = ..., - backupCount: int = ..., encoding: Optional[str] = ..., - delay: bool = ..., utc: bool = ..., - atTime: Optional[datetime.datetime] = ...) -> None: ... - else: - def __init__(self, - filename: str, when: str = ..., interval: int = ..., - backupCount: int = ..., encoding: Optional[str] = ..., - delay: bool = ..., utc: bool = ...) -> None: ... - def doRollover(self) -> None: ... -else: - class TimedRotatingFileHandler: - def __init__(self, - filename: str, when: str = ..., interval: int = ..., - backupCount: int = ..., encoding: Optional[str] = ..., - delay: bool = ..., utc: bool = ...) -> None: ... - def doRollover(self) -> None: ... - - -class SocketHandler(Handler): - retryStart = ... # type: float - retryFactor = ... # type: float - retryMax = ... # type: float - if sys.version_info >= (3, 4): - def __init__(self, host: str, port: Optional[int]) -> None: ... - else: - def __init__(self, host: str, port: int) -> None: ... - def makeSocket(self) -> SocketType: ... - def makePickle(self, record: LogRecord) -> bytes: ... - def send(self, packet: bytes) -> None: ... - def createSocket(self) -> None: ... - - -class DatagramHandler(SocketHandler): ... - - -class SysLogHandler(Handler): - LOG_ALERT = ... # type: int - LOG_CRIT = ... # type: int - LOG_DEBUG = ... # type: int - LOG_EMERG = ... # type: int - LOG_ERR = ... # type: int - LOG_INFO = ... # type: int - LOG_NOTICE = ... # type: int - LOG_WARNING = ... # type: int - LOG_AUTH = ... # type: int - LOG_AUTHPRIV = ... # type: int - LOG_CRON = ... # type: int - LOG_DAEMON = ... # type: int - LOG_FTP = ... # type: int - LOG_KERN = ... # type: int - LOG_LPR = ... # type: int - LOG_MAIL = ... # type: int - LOG_NEWS = ... # type: int - LOG_SYSLOG = ... # type: int - LOG_USER = ... # type: int - LOG_UUCP = ... # type: int - LOG_LOCAL0 = ... # type: int - LOG_LOCAL1 = ... # type: int - LOG_LOCAL2 = ... # type: int - LOG_LOCAL3 = ... # type: int - LOG_LOCAL4 = ... # type: int - LOG_LOCAL5 = ... # type: int - LOG_LOCAL6 = ... # type: int - LOG_LOCAL7 = ... # type: int - def __init__(self, address: Union[Tuple[str, int], str] = ..., - facility: int = ..., socktype: SocketKind = ...) -> None: ... - def encodePriority(self, facility: Union[int, str], - priority: Union[int, str]) -> int: ... - def mapPriority(self, levelName: int) -> str: ... - - -class NTEventLogHandler(Handler): - def __init__(self, appname: str, dllname: str = ..., - logtype: str = ...) -> None: ... - def getEventCategory(self, record: LogRecord) -> int: ... - # TODO correct return value? - def getEventType(self, record: LogRecord) -> int: ... - def getMessageID(self, record: LogRecord) -> int: ... - - -class SMTPHandler(Handler): - # TODO `secure` can also be an empty tuple - if sys.version_info >= (3,): - def __init__(self, mailhost: Union[str, Tuple[str, int]], fromaddr: str, - toaddrs: List[str], subject: str, - credentials: Optional[Tuple[str, str]] = ..., - secure: Union[Tuple[str], Tuple[str, str], None] =..., - timeout: float = ...) -> None: ... - else: - def __init__(self, - mailhost: Union[str, Tuple[str, int]], fromaddr: str, - toaddrs: List[str], subject: str, - credentials: Optional[Tuple[str, str]] = ..., - secure: Union[Tuple[str], Tuple[str, str], None] =...) -> None: ... - def getSubject(self, record: LogRecord) -> str: ... - - -class BufferingHandler(Handler): - def __init__(self, capacity: int) -> None: ... - def shouldFlush(self, record: LogRecord) -> bool: ... - -class MemoryHandler(BufferingHandler): - def __init__(self, capacity: int, flushLevel: int = ..., - target: Optional[Handler] =...) -> None: ... - def setTarget(self, target: Handler) -> None: ... - - -class HTTPHandler(Handler): - if sys.version_info >= (3, 5): - def __init__(self, host: str, url: str, method: str = ..., - secure: bool = ..., - credentials: Optional[Tuple[str, str]] = ..., - context: Optional[ssl.SSLContext] = ...) -> None: ... - elif sys.version_info >= (3,): - def __init__(self, - host: str, url: str, method: str = ..., secure: bool = ..., - credentials: Optional[Tuple[str, str]] = ...) -> None: ... - else: - def __init__(self, - host: str, url: str, method: str = ...) -> None: ... - def mapLogRecord(self, record: LogRecord) -> Dict[str, Any]: ... - - -if sys.version_info > (3,): - class QueueHandler(Handler): - def __init__(self, queue: Queue) -> None: ... - def prepare(self, record: LogRecord) -> Any: ... - def enqueue(self, record: LogRecord) -> None: ... - - class QueueListener: - if sys.version_info >= (3, 5): - def __init__(self, queue: Queue, *handlers: Handler, - respect_handler_level: bool = ...) -> None: ... - else: - def __init__(self, - queue: Queue, *handlers: Handler) -> None: ... - def dequeue(self, block: bool) -> LogRecord: ... - def prepare(self, record: LogRecord) -> Any: ... - def start(self) -> None: ... - def stop(self) -> None: ... - def enqueue_sentinel(self) -> None: ... diff --git a/typeshed/2.7/mistune.pyi b/typeshed/2.7/mistune.pyi deleted file mode 100644 index 0b9b0d95d..000000000 --- a/typeshed/2.7/mistune.pyi +++ /dev/null @@ -1,164 +0,0 @@ -# Stubs for mistune (Python 2) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -def escape(text, quote=False, smart_amp=True): ... - -class BlockGrammar: - def_links = ... # type: Any - def_footnotes = ... # type: Any - newline = ... # type: Any - block_code = ... # type: Any - fences = ... # type: Any - hrule = ... # type: Any - heading = ... # type: Any - lheading = ... # type: Any - block_quote = ... # type: Any - list_block = ... # type: Any - list_item = ... # type: Any - list_bullet = ... # type: Any - paragraph = ... # type: Any - block_html = ... # type: Any - table = ... # type: Any - nptable = ... # type: Any - text = ... # type: Any - -class BlockLexer: - grammar_class = ... # type: Any - default_rules = ... # type: Any - list_rules = ... # type: Any - footnote_rules = ... # type: Any - tokens = ... # type: Any - def_links = ... # type: Any - def_footnotes = ... # type: Any - rules = ... # type: Any - def __init__(self, rules=None, **kwargs): ... - def __call__(self, text, rules=None): ... - def parse(self, text, rules=None): ... - def parse_newline(self, m): ... - def parse_block_code(self, m): ... - def parse_fences(self, m): ... - def parse_heading(self, m): ... - def parse_lheading(self, m): ... - def parse_hrule(self, m): ... - def parse_list_block(self, m): ... - def parse_block_quote(self, m): ... - def parse_def_links(self, m): ... - def parse_def_footnotes(self, m): ... - def parse_table(self, m): ... - def parse_nptable(self, m): ... - def parse_block_html(self, m): ... - def parse_paragraph(self, m): ... - def parse_text(self, m): ... - -class InlineGrammar: - escape = ... # type: Any - inline_html = ... # type: Any - autolink = ... # type: Any - link = ... # type: Any - reflink = ... # type: Any - nolink = ... # type: Any - url = ... # type: Any - double_emphasis = ... # type: Any - emphasis = ... # type: Any - code = ... # type: Any - linebreak = ... # type: Any - strikethrough = ... # type: Any - footnote = ... # type: Any - text = ... # type: Any - def hard_wrap(self): ... - -class InlineLexer: - grammar_class = ... # type: Any - default_rules = ... # type: Any - inline_html_rules = ... # type: Any - renderer = ... # type: Any - links = ... # type: Any - footnotes = ... # type: Any - footnote_index = ... # type: Any - rules = ... # type: Any - def __init__(self, renderer, rules=None, **kwargs): ... - def __call__(self, text, rules=None): ... - def setup(self, links, footnotes): ... - line_match = ... # type: Any - line_started = ... # type: Any - def output(self, text, rules=None): ... - def output_escape(self, m): ... - def output_autolink(self, m): ... - def output_url(self, m): ... - def output_inline_html(self, m): ... - def output_footnote(self, m): ... - def output_link(self, m): ... - def output_reflink(self, m): ... - def output_nolink(self, m): ... - def output_double_emphasis(self, m): ... - def output_emphasis(self, m): ... - def output_code(self, m): ... - def output_linebreak(self, m): ... - def output_strikethrough(self, m): ... - def output_text(self, m): ... - -class Renderer: - options = ... # type: Any - def __init__(self, **kwargs) -> None: ... - def placeholder(self): ... - def block_code(self, code, lang=None): ... - def block_quote(self, text): ... - def block_html(self, html): ... - def header(self, text, level, raw=None): ... - def hrule(self): ... - def list(self, body, ordered=True): ... - def list_item(self, text): ... - def paragraph(self, text): ... - def table(self, header, body): ... - def table_row(self, content): ... - def table_cell(self, content, **flags): ... - def double_emphasis(self, text): ... - def emphasis(self, text): ... - def codespan(self, text): ... - def linebreak(self): ... - def strikethrough(self, text): ... - def text(self, text): ... - def autolink(self, link, is_email=False): ... - def link(self, link, title, text): ... - def image(self, src, title, text): ... - def inline_html(self, html): ... - def newline(self): ... - def footnote_ref(self, key, index): ... - def footnote_item(self, key, text): ... - def footnotes(self, text): ... - -class Markdown: - renderer = ... # type: Any - inline = ... # type: Any - block = ... # type: Any - footnotes = ... # type: Any - tokens = ... # type: Any - def __init__(self, renderer=None, inline=None, block=None, **kwargs): ... - def __call__(self, text): ... - def render(self, text): ... - def parse(self, text): ... - token = ... # type: Any - def pop(self): ... - def peek(self): ... - def output(self, text, rules=None): ... - def tok(self): ... - def tok_text(self): ... - def output_newline(self): ... - def output_hrule(self): ... - def output_heading(self): ... - def output_code(self): ... - def output_table(self): ... - def output_block_quote(self): ... - def output_list(self): ... - def output_list_item(self): ... - def output_loose_item(self): ... - def output_footnote(self): ... - def output_close_html(self): ... - def output_open_html(self): ... - def output_paragraph(self): ... - def output_text(self): ... - -def markdown(text: str, escape: bool=True, **kwargs) -> str: ... diff --git a/typeshed/2.7/pkg_resources/__init__.pyi b/typeshed/2.7/pkg_resources/__init__.pyi index 74f981dde..84e16603b 100644 --- a/typeshed/2.7/pkg_resources/__init__.pyi +++ b/typeshed/2.7/pkg_resources/__init__.pyi @@ -2,7 +2,7 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any +from typing import Any, Text from os import open as os_open from collections import namedtuple @@ -293,7 +293,7 @@ def parse_requirements(strs): ... def ensure_directory(path): ... def split_sections(s): ... -def resource_stream(package_or_requirement: str, resource_name: str): ... +def resource_stream(package_or_requirement: Text, resource_name: Text): ... # Names in __all__ with no definition: # add_activation_listener diff --git a/typeshed/2.7/re.pyi b/typeshed/2.7/re.pyi deleted file mode 100644 index 4c6909436..000000000 --- a/typeshed/2.7/re.pyi +++ /dev/null @@ -1,99 +0,0 @@ -# Stubs for re -# Ron Murawski -# 'bytes' support added by Jukka Lehtosalo - -# based on: http://docs.python.org/2.7/library/re.html - -from typing import ( - List, Iterator, overload, Callable, Tuple, Sequence, Dict, - Generic, AnyStr, Match, Pattern, Any, Union -) - -# ----- re variables and constants ----- -DEBUG = 0 -I = 0 -IGNORECASE = 0 -L = 0 -LOCALE = 0 -M = 0 -MULTILINE = 0 -S = 0 -DOTALL = 0 -X = 0 -VERBOSE = 0 -U = 0 -UNICODE = 0 -T = 0 -TEMPLATE = 0 - -class error(Exception): ... - -@overload -def compile(pattern: AnyStr, flags: int = ...) -> Pattern[AnyStr]: ... -@overload -def compile(pattern: Pattern[AnyStr], flags: int = ...) -> Pattern[AnyStr]: ... - -@overload -def search(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... -@overload -def search(pattern: Union[Pattern[str],Pattern[unicode]], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... - -@overload -def match(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... -@overload -def match(pattern: Union[Pattern[str],Pattern[unicode]], string: AnyStr, flags: int = ...) -> Match[AnyStr]: ... - -@overload -def split(pattern: Union[str, unicode], string: AnyStr, - maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... -@overload -def split(pattern: Union[Pattern[str],Pattern[unicode]], string: AnyStr, - maxsplit: int = ..., flags: int = ...) -> List[AnyStr]: ... - -@overload -def findall(pattern: Union[str, unicode], string: AnyStr, flags: int = ...) -> List[Any]: ... -@overload -def findall(pattern: Union[Pattern[str],Pattern[unicode]], string: AnyStr, flags: int = ...) -> List[Any]: ... - -# Return an iterator yielding match objects over all non-overlapping matches -# for the RE pattern in string. The string is scanned left-to-right, and -# matches are returned in the order found. Empty matches are included in the -# result unless they touch the beginning of another match. -@overload -def finditer(pattern: Union[str, unicode], string: AnyStr, - flags: int = ...) -> Iterator[Match[AnyStr]]: ... -@overload -def finditer(pattern: Union[Pattern[str],Pattern[unicode]], string: AnyStr, - flags: int = ...) -> Iterator[Match[AnyStr]]: ... - -@overload -def sub(pattern: Union[str, unicode], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> AnyStr: ... -@overload -def sub(pattern: Union[str, unicode], repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... -@overload -def sub(pattern: Union[Pattern[str],Pattern[unicode]], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> AnyStr: ... -@overload -def sub(pattern: Union[Pattern[str],Pattern[unicode]], repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., flags: int = ...) -> AnyStr: ... - -@overload -def subn(pattern: Union[str, unicode], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... -@overload -def subn(pattern: Union[str, unicode], repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... -@overload -def subn(pattern: Union[Pattern[str],Pattern[unicode]], repl: AnyStr, string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... -@overload -def subn(pattern: Union[Pattern[str],Pattern[unicode]], repl: Callable[[Match[AnyStr]], AnyStr], - string: AnyStr, count: int = ..., - flags: int = ...) -> Tuple[AnyStr, int]: ... - -def escape(string: AnyStr) -> AnyStr: ... - -def purge() -> None: ... diff --git a/typeshed/2.7/requests/__init__.pyi b/typeshed/2.7/requests/__init__.pyi deleted file mode 100644 index 6ea56efcc..000000000 --- a/typeshed/2.7/requests/__init__.pyi +++ /dev/null @@ -1,38 +0,0 @@ -# Stubs for requests (based on version 2.6.0, Python 3) - -from typing import Any -from requests import models -from requests import api -from requests import sessions -from requests import status_codes -from requests import exceptions -import logging - -__title__ = ... # type: Any -__build__ = ... # type: Any -__license__ = ... # type: Any -__copyright__ = ... # type: Any - -Request = models.Request -Response = models.Response -PreparedRequest = models.PreparedRequest -request = api.request -get = api.get -head = api.head -post = api.post -patch = api.patch -put = api.put -delete = api.delete -options = api.options -session = sessions.session -Session = sessions.Session -codes = status_codes.codes -RequestException = exceptions.RequestException -Timeout = exceptions.Timeout -URLRequired = exceptions.URLRequired -TooManyRedirects = exceptions.TooManyRedirects -HTTPError = exceptions.HTTPError -ConnectionError = exceptions.ConnectionError - -class NullHandler(logging.Handler): - def emit(self, record): ... diff --git a/typeshed/2.7/requests/adapters.pyi b/typeshed/2.7/requests/adapters.pyi deleted file mode 100644 index 109dc9a3e..000000000 --- a/typeshed/2.7/requests/adapters.pyi +++ /dev/null @@ -1,69 +0,0 @@ -# Stubs for requests.adapters (Python 3) - -from typing import Any -from . import models -from .packages.urllib3 import poolmanager -from .packages.urllib3 import response -from .packages.urllib3.util import retry -from . import compat -from . import utils -from . import structures -from .packages.urllib3 import exceptions as urllib3_exceptions -from . import cookies -from . import exceptions -from . import auth - -Response = models.Response -PoolManager = poolmanager.PoolManager -proxy_from_url = poolmanager.proxy_from_url -HTTPResponse = response.HTTPResponse -Retry = retry.Retry -DEFAULT_CA_BUNDLE_PATH = utils.DEFAULT_CA_BUNDLE_PATH -get_encoding_from_headers = utils.get_encoding_from_headers -prepend_scheme_if_needed = utils.prepend_scheme_if_needed -get_auth_from_url = utils.get_auth_from_url -urldefragauth = utils.urldefragauth -CaseInsensitiveDict = structures.CaseInsensitiveDict -ConnectTimeoutError = urllib3_exceptions.ConnectTimeoutError -MaxRetryError = urllib3_exceptions.MaxRetryError -ProtocolError = urllib3_exceptions.ProtocolError -ReadTimeoutError = urllib3_exceptions.ReadTimeoutError -ResponseError = urllib3_exceptions.ResponseError -extract_cookies_to_jar = cookies.extract_cookies_to_jar -ConnectionError = exceptions.ConnectionError -ConnectTimeout = exceptions.ConnectTimeout -ReadTimeout = exceptions.ReadTimeout -SSLError = exceptions.SSLError -ProxyError = exceptions.ProxyError -RetryError = exceptions.RetryError - -DEFAULT_POOLBLOCK = ... # type: Any -DEFAULT_POOLSIZE = ... # type: Any -DEFAULT_RETRIES = ... # type: Any - -class BaseAdapter: - def __init__(self) -> None: ... - # TODO: "request" parameter not actually supported, added to please mypy. - def send(self, request=...): ... - def close(self): ... - -class HTTPAdapter(BaseAdapter): - __attrs__ = ... # type: Any - max_retries = ... # type: Any - config = ... # type: Any - proxy_manager = ... # type: Any - def __init__(self, pool_connections=..., pool_maxsize=..., max_retries=..., - pool_block=...): ... - poolmanager = ... # type: Any - def init_poolmanager(self, connections, maxsize, block=..., **pool_kwargs): ... - def proxy_manager_for(self, proxy, **proxy_kwargs): ... - def cert_verify(self, conn, url, verify, cert): ... - def build_response(self, req, resp): ... - def get_connection(self, url, proxies=...): ... - def close(self): ... - def request_url(self, request, proxies): ... - def add_headers(self, request, **kwargs): ... - def proxy_headers(self, proxy): ... - # TODO: "request" is not actually optional, modified to please mypy. - def send(self, request=..., stream=..., timeout=..., verify=..., cert=..., - proxies=...): ... diff --git a/typeshed/2.7/requests/api.pyi b/typeshed/2.7/requests/api.pyi deleted file mode 100644 index 44853f72b..000000000 --- a/typeshed/2.7/requests/api.pyi +++ /dev/null @@ -1,14 +0,0 @@ -# Stubs for requests.api (Python 3) - -from typing import Union - -from .models import Response - -def request(method: str, url: str, **kwargs) -> Response: ... -def get(url: Union[str, unicode], **kwargs) -> Response: ... -def options(url: Union[str, unicode], **kwargs) -> Response: ... -def head(url: Union[str, unicode], **kwargs) -> Response: ... -def post(url: Union[str, unicode], data=..., json=..., **kwargs) -> Response: ... -def put(url: Union[str, unicode], data=..., **kwargs) -> Response: ... -def patch(url: Union[str, unicode], data=..., **kwargs) -> Response: ... -def delete(url: Union[str, unicode], **kwargs) -> Response: ... diff --git a/typeshed/2.7/requests/auth.pyi b/typeshed/2.7/requests/auth.pyi deleted file mode 100644 index 8eea2b0e0..000000000 --- a/typeshed/2.7/requests/auth.pyi +++ /dev/null @@ -1,41 +0,0 @@ -# Stubs for requests.auth (Python 3) - -from typing import Any -from . import compat -from . import cookies -from . import utils -from . import status_codes - -extract_cookies_to_jar = cookies.extract_cookies_to_jar -parse_dict_header = utils.parse_dict_header -to_native_string = utils.to_native_string -codes = status_codes.codes - -CONTENT_TYPE_FORM_URLENCODED = ... # type: Any -CONTENT_TYPE_MULTI_PART = ... # type: Any - -class AuthBase: - def __call__(self, r): ... - -class HTTPBasicAuth(AuthBase): - username = ... # type: Any - password = ... # type: Any - def __init__(self, username, password) -> None: ... - def __call__(self, r): ... - -class HTTPProxyAuth(HTTPBasicAuth): - def __call__(self, r): ... - -class HTTPDigestAuth(AuthBase): - username = ... # type: Any - password = ... # type: Any - last_nonce = ... # type: Any - nonce_count = ... # type: Any - chal = ... # type: Any - pos = ... # type: Any - num_401_calls = ... # type: Any - def __init__(self, username, password) -> None: ... - def build_digest_header(self, method, url): ... - def handle_redirect(self, r, **kwargs): ... - def handle_401(self, r, **kwargs): ... - def __call__(self, r): ... diff --git a/typeshed/2.7/requests/compat.pyi b/typeshed/2.7/requests/compat.pyi deleted file mode 100644 index 63b92f6fe..000000000 --- a/typeshed/2.7/requests/compat.pyi +++ /dev/null @@ -1,6 +0,0 @@ -# Stubs for requests.compat (Python 3.4) - -from typing import Any -import collections - -OrderedDict = collections.OrderedDict diff --git a/typeshed/2.7/requests/cookies.pyi b/typeshed/2.7/requests/cookies.pyi deleted file mode 100644 index 6f56c82fb..000000000 --- a/typeshed/2.7/requests/cookies.pyi +++ /dev/null @@ -1,61 +0,0 @@ -# Stubs for requests.cookies (Python 3) - -from typing import Any, MutableMapping -import collections -from . import compat - -class MockRequest: - type = ... # type: Any - def __init__(self, request) -> None: ... - def get_type(self): ... - def get_host(self): ... - def get_origin_req_host(self): ... - def get_full_url(self): ... - def is_unverifiable(self): ... - def has_header(self, name): ... - def get_header(self, name, default=...): ... - def add_header(self, key, val): ... - def add_unredirected_header(self, name, value): ... - def get_new_headers(self): ... - @property - def unverifiable(self): ... - @property - def origin_req_host(self): ... - @property - def host(self): ... - -class MockResponse: - def __init__(self, headers) -> None: ... - def info(self): ... - def getheaders(self, name): ... - -def extract_cookies_to_jar(jar, request, response): ... -def get_cookie_header(jar, request): ... -def remove_cookie_by_name(cookiejar, name, domain=..., path=...): ... - -class CookieConflictError(RuntimeError): ... - -class RequestsCookieJar(MutableMapping): - def get(self, name, default=..., domain=..., path=...): ... - def set(self, name, value, **kwargs): ... - def iterkeys(self): ... - def keys(self): ... - def itervalues(self): ... - def values(self): ... - def iteritems(self): ... - def items(self): ... - def list_domains(self): ... - def list_paths(self): ... - def multiple_domains(self): ... - def get_dict(self, domain=..., path=...): ... - def __getitem__(self, name): ... - def __setitem__(self, name, value): ... - def __delitem__(self, name): ... - def set_cookie(self, cookie, *args, **kwargs): ... - def update(self, other): ... - def copy(self): ... - -def create_cookie(name, value, **kwargs): ... -def morsel_to_cookie(morsel): ... -def cookiejar_from_dict(cookie_dict, cookiejar=..., overwrite=...): ... -def merge_cookies(cookiejar, cookies): ... diff --git a/typeshed/2.7/requests/exceptions.pyi b/typeshed/2.7/requests/exceptions.pyi deleted file mode 100644 index ff0c32883..000000000 --- a/typeshed/2.7/requests/exceptions.pyi +++ /dev/null @@ -1,26 +0,0 @@ -# Stubs for requests.exceptions (Python 3) - -from typing import Any -from .packages.urllib3.exceptions import HTTPError as BaseHTTPError - -class RequestException(IOError): - response = ... # type: Any - request = ... # type: Any - def __init__(self, *args, **kwargs) -> None: ... - -class HTTPError(RequestException): ... -class ConnectionError(RequestException): ... -class ProxyError(ConnectionError): ... -class SSLError(ConnectionError): ... -class Timeout(RequestException): ... -class ConnectTimeout(ConnectionError, Timeout): ... -class ReadTimeout(Timeout): ... -class URLRequired(RequestException): ... -class TooManyRedirects(RequestException): ... -class MissingSchema(RequestException, ValueError): ... -class InvalidSchema(RequestException, ValueError): ... -class InvalidURL(RequestException, ValueError): ... -class ChunkedEncodingError(RequestException): ... -class ContentDecodingError(RequestException, BaseHTTPError): ... -class StreamConsumedError(RequestException, TypeError): ... -class RetryError(RequestException): ... diff --git a/typeshed/2.7/requests/hooks.pyi b/typeshed/2.7/requests/hooks.pyi deleted file mode 100644 index 3367d9a48..000000000 --- a/typeshed/2.7/requests/hooks.pyi +++ /dev/null @@ -1,8 +0,0 @@ -# Stubs for requests.hooks (Python 3) - -from typing import Any - -HOOKS = ... # type: Any - -def default_hooks(): ... -def dispatch_hook(key, hooks, hook_data, **kwargs): ... diff --git a/typeshed/2.7/requests/models.pyi b/typeshed/2.7/requests/models.pyi deleted file mode 100644 index d400d4a06..000000000 --- a/typeshed/2.7/requests/models.pyi +++ /dev/null @@ -1,133 +0,0 @@ -# Stubs for requests.models (Python 3) - -from typing import Any, List, MutableMapping, Iterator, Dict -import datetime - -from . import hooks -from . import structures -from . import auth -from . import cookies -from .cookies import RequestsCookieJar -from .packages.urllib3 import fields -from .packages.urllib3 import filepost -from .packages.urllib3 import util -from .packages.urllib3 import exceptions as urllib3_exceptions -from . import exceptions -from . import utils -from . import compat -from . import status_codes - -default_hooks = hooks.default_hooks -CaseInsensitiveDict = structures.CaseInsensitiveDict -HTTPBasicAuth = auth.HTTPBasicAuth -cookiejar_from_dict = cookies.cookiejar_from_dict -get_cookie_header = cookies.get_cookie_header -RequestField = fields.RequestField -encode_multipart_formdata = filepost.encode_multipart_formdata -DecodeError = urllib3_exceptions.DecodeError -ReadTimeoutError = urllib3_exceptions.ReadTimeoutError -ProtocolError = urllib3_exceptions.ProtocolError -LocationParseError = urllib3_exceptions.LocationParseError -HTTPError = exceptions.HTTPError -MissingSchema = exceptions.MissingSchema -InvalidURL = exceptions.InvalidURL -ChunkedEncodingError = exceptions.ChunkedEncodingError -ContentDecodingError = exceptions.ContentDecodingError -ConnectionError = exceptions.ConnectionError -StreamConsumedError = exceptions.StreamConsumedError -guess_filename = utils.guess_filename -get_auth_from_url = utils.get_auth_from_url -requote_uri = utils.requote_uri -stream_decode_response_unicode = utils.stream_decode_response_unicode -to_key_val_list = utils.to_key_val_list -parse_header_links = utils.parse_header_links -iter_slices = utils.iter_slices -guess_json_utf = utils.guess_json_utf -super_len = utils.super_len -to_native_string = utils.to_native_string -codes = status_codes.codes - -REDIRECT_STATI = ... # type: Any -DEFAULT_REDIRECT_LIMIT = ... # type: Any -CONTENT_CHUNK_SIZE = ... # type: Any -ITER_CHUNK_SIZE = ... # type: Any -json_dumps = ... # type: Any - -class RequestEncodingMixin: - @property - def path_url(self): ... - -class RequestHooksMixin: - def register_hook(self, event, hook): ... - def deregister_hook(self, event, hook): ... - -class Request(RequestHooksMixin): - hooks = ... # type: Any - method = ... # type: Any - url = ... # type: Any - headers = ... # type: Any - files = ... # type: Any - data = ... # type: Any - json = ... # type: Any - params = ... # type: Any - auth = ... # type: Any - cookies = ... # type: Any - def __init__(self, method=..., url=..., headers=..., files=..., data=..., params=..., - auth=..., cookies=..., hooks=..., json=...): ... - def prepare(self): ... - -class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): - method = ... # type: Any - url = ... # type: Any - headers = ... # type: Any - body = ... # type: Any - hooks = ... # type: Any - def __init__(self) -> None: ... - def prepare(self, method=..., url=..., headers=..., files=..., data=..., params=..., - auth=..., cookies=..., hooks=..., json=...): ... - def copy(self): ... - def prepare_method(self, method): ... - def prepare_url(self, url, params): ... - def prepare_headers(self, headers): ... - def prepare_body(self, data, files, json=...): ... - def prepare_content_length(self, body): ... - def prepare_auth(self, auth, url=...): ... - def prepare_cookies(self, cookies): ... - def prepare_hooks(self, hooks): ... - -class Response: - __attrs__ = ... # type: Any - status_code = ... # type: int - headers = ... # type: MutableMapping[str, str] - raw = ... # type: Any - url = ... # type: str - encoding = ... # type: str - history = ... # type: List[Response] - reason = ... # type: str - cookies = ... # type: RequestsCookieJar - elapsed = ... # type: datetime.timedelta - request = ... # type: PreparedRequest - def __init__(self) -> None: ... - def __bool__(self) -> bool: ... - def __nonzero__(self) -> bool: ... - def __iter__(self) -> Iterator[str]: ... - @property - def ok(self) -> bool: ... - @property - def is_redirect(self) -> bool: ... - @property - def is_permanent_redirect(self) -> bool: ... - @property - def apparent_encoding(self) -> str: ... - def iter_content(self, chunk_size: int = ..., - decode_unicode: bool = ...) -> Iterator[Any]: ... - def iter_lines(self, chunk_size=..., decode_unicode=..., delimiter=...): ... - @property - def content(self) -> str: ... - @property - def text(self) -> str: ... - def json(self, **kwargs) -> Any: ... - @property - def links(self) -> Dict[Any, Any]: ... - def raise_for_status(self) -> None: ... - def close(self) -> None: ... diff --git a/typeshed/2.7/requests/packages/__init__.pyi b/typeshed/2.7/requests/packages/__init__.pyi deleted file mode 100644 index 2b1bff828..000000000 --- a/typeshed/2.7/requests/packages/__init__.pyi +++ /dev/null @@ -1,8 +0,0 @@ -# Stubs for requests.packages (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -class VendorAlias: - def __init__(self, package_names) -> None: ... - def find_module(self, fullname, path=...): ... - def load_module(self, name): ... diff --git a/typeshed/2.7/requests/packages/urllib3/__init__.pyi b/typeshed/2.7/requests/packages/urllib3/__init__.pyi deleted file mode 100644 index 38cf6729c..000000000 --- a/typeshed/2.7/requests/packages/urllib3/__init__.pyi +++ /dev/null @@ -1,12 +0,0 @@ -# Stubs for requests.packages.urllib3 (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -import logging - -class NullHandler(logging.Handler): - def emit(self, record): ... - -def add_stderr_logger(level=...): ... -def disable_warnings(category=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/_collections.pyi b/typeshed/2.7/requests/packages/urllib3/_collections.pyi deleted file mode 100644 index 58aa94422..000000000 --- a/typeshed/2.7/requests/packages/urllib3/_collections.pyi +++ /dev/null @@ -1,51 +0,0 @@ -# Stubs for requests.packages.urllib3._collections (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from collections import MutableMapping - -class RLock: - def __enter__(self): ... - def __exit__(self, exc_type, exc_value, traceback): ... - -class RecentlyUsedContainer(MutableMapping): - ContainerCls = ... # type: Any - dispose_func = ... # type: Any - lock = ... # type: Any - def __init__(self, maxsize=..., dispose_func=...) -> None: ... - def __getitem__(self, key): ... - def __setitem__(self, key, value): ... - def __delitem__(self, key): ... - def __len__(self): ... - def __iter__(self): ... - def clear(self): ... - def keys(self): ... - -class HTTPHeaderDict(dict): - def __init__(self, headers=..., **kwargs) -> None: ... - def __setitem__(self, key, val): ... - def __getitem__(self, key): ... - def __delitem__(self, key): ... - def __contains__(self, key): ... - def __eq__(self, other): ... - def __ne__(self, other): ... - values = ... # type: Any - get = ... # type: Any - update = ... # type: Any - iterkeys = ... # type: Any - itervalues = ... # type: Any - def pop(self, key, default=...): ... - def discard(self, key): ... - def add(self, key, val): ... - def extend(*args, **kwargs): ... - def getlist(self, key): ... - getheaders = ... # type: Any - getallmatchingheaders = ... # type: Any - iget = ... # type: Any - def copy(self): ... - def iteritems(self): ... - def itermerged(self): ... - def items(self): ... - @classmethod - def from_httplib(cls, message, duplicates=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/connection.pyi b/typeshed/2.7/requests/packages/urllib3/connection.pyi deleted file mode 100644 index 289fd1836..000000000 --- a/typeshed/2.7/requests/packages/urllib3/connection.pyi +++ /dev/null @@ -1,51 +0,0 @@ -# Stubs for requests.packages.urllib3.connection (Python 3.4) - -from typing import Any -from httplib import HTTPException -from . import packages -from . import exceptions -from . import util - -class DummyConnection: ... - -ConnectTimeoutError = exceptions.ConnectTimeoutError -SystemTimeWarning = exceptions.SystemTimeWarning -SecurityWarning = exceptions.SecurityWarning - -port_by_scheme = ... # type: Any -RECENT_DATE = ... # type: Any - -class HTTPConnection(object): - default_port = ... # type: Any - default_socket_options = ... # type: Any - is_verified = ... # type: Any - source_address = ... # type: Any - socket_options = ... # type: Any - def __init__(self, *args, **kw) -> None: ... - def connect(self): ... - -class HTTPSConnection(HTTPConnection): - default_port = ... # type: Any - key_file = ... # type: Any - cert_file = ... # type: Any - def __init__(self, host, port=..., key_file=..., cert_file=..., strict=..., timeout=..., **kw) -> None: ... - sock = ... # type: Any - def connect(self): ... - -class VerifiedHTTPSConnection(HTTPSConnection): - cert_reqs = ... # type: Any - ca_certs = ... # type: Any - ssl_version = ... # type: Any - assert_fingerprint = ... # type: Any - key_file = ... # type: Any - cert_file = ... # type: Any - assert_hostname = ... # type: Any - def set_cert(self, key_file=..., cert_file=..., cert_reqs=..., ca_certs=..., assert_hostname=..., assert_fingerprint=...): ... - sock = ... # type: Any - auto_open = ... # type: Any - is_verified = ... # type: Any - def connect(self): ... - -UnverifiedHTTPSConnection = ... # type: Any - -class ConnectionError(Exception): pass diff --git a/typeshed/2.7/requests/packages/urllib3/connectionpool.pyi b/typeshed/2.7/requests/packages/urllib3/connectionpool.pyi deleted file mode 100644 index 03c3140f2..000000000 --- a/typeshed/2.7/requests/packages/urllib3/connectionpool.pyi +++ /dev/null @@ -1,87 +0,0 @@ -# Stubs for requests.packages.urllib3.connectionpool (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from ssl import SSLError as BaseSSLError -from . import exceptions -from .packages import ssl_match_hostname -from . import packages -from . import connection -from . import request -from . import response -from .util import connection as _connection -from .util import retry -from .util import timeout -from .util import url - -ClosedPoolError = exceptions.ClosedPoolError -ProtocolError = exceptions.ProtocolError -EmptyPoolError = exceptions.EmptyPoolError -HostChangedError = exceptions.HostChangedError -LocationValueError = exceptions.LocationValueError -MaxRetryError = exceptions.MaxRetryError -ProxyError = exceptions.ProxyError -ReadTimeoutError = exceptions.ReadTimeoutError -SSLError = exceptions.SSLError -TimeoutError = exceptions.TimeoutError -InsecureRequestWarning = exceptions.InsecureRequestWarning -CertificateError = ssl_match_hostname.CertificateError -port_by_scheme = connection.port_by_scheme -DummyConnection = connection.DummyConnection -HTTPConnection = connection.HTTPConnection -HTTPSConnection = connection.HTTPSConnection -VerifiedHTTPSConnection = connection.VerifiedHTTPSConnection -HTTPException = connection.HTTPException -ConnectionError = connection.ConnectionError -RequestMethods = request.RequestMethods -HTTPResponse = response.HTTPResponse -is_connection_dropped = _connection.is_connection_dropped -Retry = retry.Retry -Timeout = timeout.Timeout -get_host = url.get_host - -xrange = ... # type: Any -log = ... # type: Any - -class ConnectionPool: - scheme = ... # type: Any - QueueCls = ... # type: Any - host = ... # type: Any - port = ... # type: Any - def __init__(self, host, port=...) -> None: ... - def __enter__(self): ... - def __exit__(self, exc_type, exc_val, exc_tb): ... - def close(self): ... - -class HTTPConnectionPool(ConnectionPool, RequestMethods): - scheme = ... # type: Any - ConnectionCls = ... # type: Any - strict = ... # type: Any - timeout = ... # type: Any - retries = ... # type: Any - pool = ... # type: Any - block = ... # type: Any - proxy = ... # type: Any - proxy_headers = ... # type: Any - num_connections = ... # type: Any - num_requests = ... # type: Any - conn_kw = ... # type: Any - def __init__(self, host, port=..., strict=..., timeout=..., maxsize=..., block=..., headers=..., retries=..., _proxy=..., _proxy_headers=..., **conn_kw) -> None: ... - def close(self): ... - def is_same_host(self, url): ... - def urlopen(self, method, url, body=..., headers=..., retries=..., redirect=..., assert_same_host=..., timeout=..., pool_timeout=..., release_conn=..., **response_kw): ... - -class HTTPSConnectionPool(HTTPConnectionPool): - scheme = ... # type: Any - ConnectionCls = ... # type: Any - key_file = ... # type: Any - cert_file = ... # type: Any - cert_reqs = ... # type: Any - ca_certs = ... # type: Any - ssl_version = ... # type: Any - assert_hostname = ... # type: Any - assert_fingerprint = ... # type: Any - def __init__(self, host, port=..., strict=..., timeout=..., maxsize=..., block=..., headers=..., retries=..., _proxy=..., _proxy_headers=..., key_file=..., cert_file=..., cert_reqs=..., ca_certs=..., ssl_version=..., assert_hostname=..., assert_fingerprint=..., **conn_kw) -> None: ... - -def connection_from_url(url, **kw): ... diff --git a/typeshed/2.7/requests/packages/urllib3/contrib/__init__.pyi b/typeshed/2.7/requests/packages/urllib3/contrib/__init__.pyi deleted file mode 100644 index 17d26bb13..000000000 --- a/typeshed/2.7/requests/packages/urllib3/contrib/__init__.pyi +++ /dev/null @@ -1,4 +0,0 @@ -# Stubs for requests.packages.urllib3.contrib (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - diff --git a/typeshed/2.7/requests/packages/urllib3/exceptions.pyi b/typeshed/2.7/requests/packages/urllib3/exceptions.pyi deleted file mode 100644 index 3e7d0f6c9..000000000 --- a/typeshed/2.7/requests/packages/urllib3/exceptions.pyi +++ /dev/null @@ -1,54 +0,0 @@ -# Stubs for requests.packages.urllib3.exceptions (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -class HTTPError(Exception): ... -class HTTPWarning(Warning): ... - -class PoolError(HTTPError): - pool = ... # type: Any - def __init__(self, pool, message) -> None: ... - def __reduce__(self): ... - -class RequestError(PoolError): - url = ... # type: Any - def __init__(self, pool, url, message) -> None: ... - def __reduce__(self): ... - -class SSLError(HTTPError): ... -class ProxyError(HTTPError): ... -class DecodeError(HTTPError): ... -class ProtocolError(HTTPError): ... - -ConnectionError = ... # type: Any - -class MaxRetryError(RequestError): - reason = ... # type: Any - def __init__(self, pool, url, reason=...) -> None: ... - -class HostChangedError(RequestError): - retries = ... # type: Any - def __init__(self, pool, url, retries=...) -> None: ... - -class TimeoutStateError(HTTPError): ... -class TimeoutError(HTTPError): ... -class ReadTimeoutError(TimeoutError, RequestError): ... -class ConnectTimeoutError(TimeoutError): ... -class EmptyPoolError(PoolError): ... -class ClosedPoolError(PoolError): ... -class LocationValueError(ValueError, HTTPError): ... - -class LocationParseError(LocationValueError): - location = ... # type: Any - def __init__(self, location) -> None: ... - -class ResponseError(HTTPError): - GENERIC_ERROR = ... # type: Any - SPECIFIC_ERROR = ... # type: Any - -class SecurityWarning(HTTPWarning): ... -class InsecureRequestWarning(SecurityWarning): ... -class SystemTimeWarning(SecurityWarning): ... -class InsecurePlatformWarning(SecurityWarning): ... diff --git a/typeshed/2.7/requests/packages/urllib3/fields.pyi b/typeshed/2.7/requests/packages/urllib3/fields.pyi deleted file mode 100644 index cdc7734e2..000000000 --- a/typeshed/2.7/requests/packages/urllib3/fields.pyi +++ /dev/null @@ -1,16 +0,0 @@ -# Stubs for requests.packages.urllib3.fields (Python 3.4) - -from typing import Any -from . import packages - -def guess_content_type(filename, default=...): ... -def format_header_param(name, value): ... - -class RequestField: - data = ... # type: Any - headers = ... # type: Any - def __init__(self, name, data, filename=..., headers=...) -> None: ... - @classmethod - def from_tuples(cls, fieldname, value): ... - def render_headers(self): ... - def make_multipart(self, content_disposition=..., content_type=..., content_location=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/filepost.pyi b/typeshed/2.7/requests/packages/urllib3/filepost.pyi deleted file mode 100644 index c6fefa618..000000000 --- a/typeshed/2.7/requests/packages/urllib3/filepost.pyi +++ /dev/null @@ -1,19 +0,0 @@ -# Stubs for requests.packages.urllib3.filepost (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from . import packages -#from .packages import six -from . import fields - -#six = packages.six -#b = six.b -RequestField = fields.RequestField - -writer = ... # type: Any - -def choose_boundary(): ... -def iter_field_objects(fields): ... -def iter_fields(fields): ... -def encode_multipart_formdata(fields, boundary=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/packages/__init__.pyi b/typeshed/2.7/requests/packages/urllib3/packages/__init__.pyi deleted file mode 100644 index 231463649..000000000 --- a/typeshed/2.7/requests/packages/urllib3/packages/__init__.pyi +++ /dev/null @@ -1,4 +0,0 @@ -# Stubs for requests.packages.urllib3.packages (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - diff --git a/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi b/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi deleted file mode 100644 index 05c03dc08..000000000 --- a/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/__init__.pyi +++ /dev/null @@ -1 +0,0 @@ -class CertificateError(ValueError): pass diff --git a/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi b/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi deleted file mode 100644 index 5abbc9dd5..000000000 --- a/typeshed/2.7/requests/packages/urllib3/packages/ssl_match_hostname/_implementation.pyi +++ /dev/null @@ -1,7 +0,0 @@ -# Stubs for requests.packages.urllib3.packages.ssl_match_hostname._implementation (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -class CertificateError(ValueError): ... - -def match_hostname(cert, hostname): ... diff --git a/typeshed/2.7/requests/packages/urllib3/poolmanager.pyi b/typeshed/2.7/requests/packages/urllib3/poolmanager.pyi deleted file mode 100644 index a65f66497..000000000 --- a/typeshed/2.7/requests/packages/urllib3/poolmanager.pyi +++ /dev/null @@ -1,31 +0,0 @@ -# Stubs for requests.packages.urllib3.poolmanager (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from .request import RequestMethods - -class PoolManager(RequestMethods): - proxy = ... # type: Any - connection_pool_kw = ... # type: Any - pools = ... # type: Any - def __init__(self, num_pools=..., headers=..., **connection_pool_kw) -> None: ... - def __enter__(self): ... - def __exit__(self, exc_type, exc_val, exc_tb): ... - def clear(self): ... - def connection_from_host(self, host, port=..., scheme=...): ... - def connection_from_url(self, url): ... - # TODO: This was the original signature -- copied another one from base class to fix complaint. - # def urlopen(self, method, url, redirect=True, **kw): ... - def urlopen(self, method, url, body=..., headers=..., encode_multipart=..., multipart_boundary=..., **kw): ... - -class ProxyManager(PoolManager): - proxy = ... # type: Any - proxy_headers = ... # type: Any - def __init__(self, proxy_url, num_pools=..., headers=..., proxy_headers=..., **connection_pool_kw) -> None: ... - def connection_from_host(self, host, port=..., scheme=...): ... - # TODO: This was the original signature -- copied another one from base class to fix complaint. - # def urlopen(self, method, url, redirect=True, **kw): ... - def urlopen(self, method, url, body=..., headers=..., encode_multipart=..., multipart_boundary=..., **kw): ... - -def proxy_from_url(url, **kw): ... diff --git a/typeshed/2.7/requests/packages/urllib3/request.pyi b/typeshed/2.7/requests/packages/urllib3/request.pyi deleted file mode 100644 index 788c759c5..000000000 --- a/typeshed/2.7/requests/packages/urllib3/request.pyi +++ /dev/null @@ -1,13 +0,0 @@ -# Stubs for requests.packages.urllib3.request (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -class RequestMethods: - headers = ... # type: Any - def __init__(self, headers=...) -> None: ... - def urlopen(self, method, url, body=..., headers=..., encode_multipart=..., multipart_boundary=..., **kw): ... - def request(self, method, url, fields=..., headers=..., **urlopen_kw): ... - def request_encode_url(self, method, url, fields=..., **urlopen_kw): ... - def request_encode_body(self, method, url, fields=..., headers=..., encode_multipart=..., multipart_boundary=..., **urlopen_kw): ... diff --git a/typeshed/2.7/requests/packages/urllib3/response.pyi b/typeshed/2.7/requests/packages/urllib3/response.pyi deleted file mode 100644 index c84f7e91f..000000000 --- a/typeshed/2.7/requests/packages/urllib3/response.pyi +++ /dev/null @@ -1,58 +0,0 @@ -# Stubs for requests.packages.urllib3.response (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any, IO -import io -from . import _collections -from . import exceptions -#from .packages import six -from . import connection -from .util import response - -HTTPHeaderDict = _collections.HTTPHeaderDict -ProtocolError = exceptions.ProtocolError -DecodeError = exceptions.DecodeError -ReadTimeoutError = exceptions.ReadTimeoutError -binary_type = str # six.binary_type -PY3 = True # six.PY3 -is_fp_closed = response.is_fp_closed - -class DeflateDecoder: - def __init__(self) -> None: ... - def __getattr__(self, name): ... - def decompress(self, data): ... - -class GzipDecoder: - def __init__(self) -> None: ... - def __getattr__(self, name): ... - def decompress(self, data): ... - -class HTTPResponse(IO[Any]): - CONTENT_DECODERS = ... # type: Any - REDIRECT_STATUSES = ... # type: Any - headers = ... # type: Any - status = ... # type: Any - version = ... # type: Any - reason = ... # type: Any - strict = ... # type: Any - decode_content = ... # type: Any - def __init__(self, body=..., headers=..., status=..., version=..., reason=..., strict=..., preload_content=..., decode_content=..., original_response=..., pool=..., connection=...) -> None: ... - def get_redirect_location(self): ... - def release_conn(self): ... - @property - def data(self): ... - def tell(self): ... - def read(self, amt=..., decode_content=..., cache_content=...): ... - def stream(self, amt=..., decode_content=...): ... - @classmethod - def from_httplib(ResponseCls, r, **response_kw): ... - def getheaders(self): ... - def getheader(self, name, default=...): ... - def close(self): ... - @property - def closed(self): ... - def fileno(self): ... - def flush(self): ... - def readable(self): ... - def readinto(self, b): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/__init__.pyi b/typeshed/2.7/requests/packages/urllib3/util/__init__.pyi deleted file mode 100644 index eca2ea93d..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/__init__.pyi +++ /dev/null @@ -1,7 +0,0 @@ -# Stubs for requests.packages.urllib3.util (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from . import connection -from . import request - diff --git a/typeshed/2.7/requests/packages/urllib3/util/connection.pyi b/typeshed/2.7/requests/packages/urllib3/util/connection.pyi deleted file mode 100644 index cd673098c..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/connection.pyi +++ /dev/null @@ -1,11 +0,0 @@ -# Stubs for requests.packages.urllib3.util.connection (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any - -poll = ... # type: Any -select = ... # type: Any - -def is_connection_dropped(conn): ... -def create_connection(address, timeout=..., source_address=..., socket_options=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/request.pyi b/typeshed/2.7/requests/packages/urllib3/util/request.pyi deleted file mode 100644 index 20a6ea277..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/request.pyi +++ /dev/null @@ -1,12 +0,0 @@ -# Stubs for requests.packages.urllib3.util.request (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -#from ..packages import six - -#b = six.b - -ACCEPT_ENCODING = ... # type: Any - -def make_headers(keep_alive=..., accept_encoding=..., user_agent=..., basic_auth=..., proxy_basic_auth=..., disable_cache=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/response.pyi b/typeshed/2.7/requests/packages/urllib3/util/response.pyi deleted file mode 100644 index 761a00679..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/response.pyi +++ /dev/null @@ -1,5 +0,0 @@ -# Stubs for requests.packages.urllib3.util.response (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -def is_fp_closed(obj): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/retry.pyi b/typeshed/2.7/requests/packages/urllib3/util/retry.pyi deleted file mode 100644 index e958d9061..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/retry.pyi +++ /dev/null @@ -1,36 +0,0 @@ -# Stubs for requests.packages.urllib3.util.retry (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from .. import exceptions -from .. import packages - -ConnectTimeoutError = exceptions.ConnectTimeoutError -MaxRetryError = exceptions.MaxRetryError -ProtocolError = exceptions.ProtocolError -ReadTimeoutError = exceptions.ReadTimeoutError -ResponseError = exceptions.ResponseError - -log = ... # type: Any - -class Retry: - DEFAULT_METHOD_WHITELIST = ... # type: Any - BACKOFF_MAX = ... # type: Any - total = ... # type: Any - connect = ... # type: Any - read = ... # type: Any - redirect = ... # type: Any - status_forcelist = ... # type: Any - method_whitelist = ... # type: Any - backoff_factor = ... # type: Any - raise_on_redirect = ... # type: Any - def __init__(self, total=..., connect=..., read=..., redirect=..., method_whitelist=..., status_forcelist=..., backoff_factor=..., raise_on_redirect=..., _observed_errors=...) -> None: ... - def new(self, **kw): ... - @classmethod - def from_int(cls, retries, redirect=..., default=...): ... - def get_backoff_time(self): ... - def sleep(self): ... - def is_forced_retry(self, method, status_code): ... - def is_exhausted(self): ... - def increment(self, method=..., url=..., response=..., error=..., _pool=..., _stacktrace=...): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/timeout.pyi b/typeshed/2.7/requests/packages/urllib3/util/timeout.pyi deleted file mode 100644 index 0a7653c5f..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/timeout.pyi +++ /dev/null @@ -1,24 +0,0 @@ -# Stubs for requests.packages.urllib3.util.timeout (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from .. import exceptions - -TimeoutStateError = exceptions.TimeoutStateError - -def current_time(): ... - -class Timeout: - DEFAULT_TIMEOUT = ... # type: Any - total = ... # type: Any - def __init__(self, total=..., connect=..., read=...) -> None: ... - @classmethod - def from_float(cls, timeout): ... - def clone(self): ... - def start_connect(self): ... - def get_connect_duration(self): ... - @property - def connect_timeout(self): ... - @property - def read_timeout(self): ... diff --git a/typeshed/2.7/requests/packages/urllib3/util/url.pyi b/typeshed/2.7/requests/packages/urllib3/util/url.pyi deleted file mode 100644 index 9877b4a17..000000000 --- a/typeshed/2.7/requests/packages/urllib3/util/url.pyi +++ /dev/null @@ -1,26 +0,0 @@ -# Stubs for requests.packages.urllib3.util.url (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from .. import exceptions - -LocationParseError = exceptions.LocationParseError - -url_attrs = ... # type: Any - -class Url: - slots = ... # type: Any - def __new__(cls, scheme=..., auth=..., host=..., port=..., path=..., query=..., fragment=...): ... - @property - def hostname(self): ... - @property - def request_uri(self): ... - @property - def netloc(self): ... - @property - def url(self): ... - -def split_first(s, delims): ... -def parse_url(url): ... -def get_host(url): ... diff --git a/typeshed/2.7/requests/sessions.pyi b/typeshed/2.7/requests/sessions.pyi deleted file mode 100644 index b9f49cbb1..000000000 --- a/typeshed/2.7/requests/sessions.pyi +++ /dev/null @@ -1,92 +0,0 @@ -# Stubs for requests.sessions (Python 3) - -from typing import Any, AnyStr, Union, MutableMapping -from . import auth -from . import compat -from . import cookies -from . import models -from .models import Response -from . import hooks -from . import utils -from . import exceptions -from .packages.urllib3 import _collections -from . import structures -from . import adapters -from . import status_codes - -OrderedDict = compat.OrderedDict -cookiejar_from_dict = cookies.cookiejar_from_dict -extract_cookies_to_jar = cookies.extract_cookies_to_jar -RequestsCookieJar = cookies.RequestsCookieJar -merge_cookies = cookies.merge_cookies -Request = models.Request -PreparedRequest = models.PreparedRequest -DEFAULT_REDIRECT_LIMIT = models.DEFAULT_REDIRECT_LIMIT -default_hooks = hooks.default_hooks -dispatch_hook = hooks.dispatch_hook -to_key_val_list = utils.to_key_val_list -default_headers = utils.default_headers -to_native_string = utils.to_native_string -TooManyRedirects = exceptions.TooManyRedirects -InvalidSchema = exceptions.InvalidSchema -ChunkedEncodingError = exceptions.ChunkedEncodingError -ContentDecodingError = exceptions.ContentDecodingError -RecentlyUsedContainer = _collections.RecentlyUsedContainer -CaseInsensitiveDict = structures.CaseInsensitiveDict -HTTPAdapter = adapters.HTTPAdapter -requote_uri = utils.requote_uri -get_environ_proxies = utils.get_environ_proxies -get_netrc_auth = utils.get_netrc_auth -should_bypass_proxies = utils.should_bypass_proxies -get_auth_from_url = utils.get_auth_from_url -codes = status_codes.codes -REDIRECT_STATI = models.REDIRECT_STATI - -REDIRECT_CACHE_SIZE = ... # type: Any - -def merge_setting(request_setting, session_setting, dict_class=...): ... -def merge_hooks(request_hooks, session_hooks, dict_class=...): ... - -class SessionRedirectMixin: - def resolve_redirects(self, resp, req, stream=..., timeout=..., verify=..., cert=..., - proxies=...): ... - def rebuild_auth(self, prepared_request, response): ... - def rebuild_proxies(self, prepared_request, proxies): ... - -class Session(SessionRedirectMixin): - __attrs__ = ... # type: Any - headers = ... # type: MutableMapping[str, str] - auth = ... # type: Any - proxies = ... # type: Any - hooks = ... # type: Any - params = ... # type: Any - stream = ... # type: Any - verify = ... # type: Any - cert = ... # type: Any - max_redirects = ... # type: Any - trust_env = ... # type: Any - cookies = ... # type: Any - adapters = ... # type: Any - redirect_cache = ... # type: Any - def __init__(self) -> None: ... - def __enter__(self) -> 'Session': ... - def __exit__(self, *args) -> None: ... - def prepare_request(self, request): ... - def request(self, method: str, url: str, params=..., data=..., headers=..., - cookies=..., files=..., auth=..., timeout=..., allow_redirects=..., - proxies=..., hooks=..., stream=..., verify=..., cert=..., - json=...) -> Response: ... - def get(self, url: AnyStr, **kwargs) -> Response: ... - def options(self, url: str, **kwargs) -> Response: ... - def head(self, url: AnyStr, **kwargs) -> Response: ... - def post(self, url: str, data=..., json=..., **kwargs) -> Response: ... - def put(self, url: str, data=..., **kwargs) -> Response: ... - def patch(self, url: str, data=..., **kwargs) -> Response: ... - def delete(self, url: str, **kwargs) -> Response: ... - def send(self, request, **kwargs): ... - def merge_environment_settings(self, url, proxies, stream, verify, cert): ... - def get_adapter(self, url): ... - def close(self) -> None: ... - def mount(self, prefix, adapter): ... - -def session() -> Session: ... diff --git a/typeshed/2.7/requests/status_codes.pyi b/typeshed/2.7/requests/status_codes.pyi deleted file mode 100644 index e3035eb91..000000000 --- a/typeshed/2.7/requests/status_codes.pyi +++ /dev/null @@ -1,8 +0,0 @@ -# Stubs for requests.status_codes (Python 3) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. - -from typing import Any -from .structures import LookupDict - -codes = ... # type: Any diff --git a/typeshed/2.7/requests/structures.pyi b/typeshed/2.7/requests/structures.pyi deleted file mode 100644 index 837cf2501..000000000 --- a/typeshed/2.7/requests/structures.pyi +++ /dev/null @@ -1,21 +0,0 @@ -# Stubs for requests.structures (Python 3) - -from typing import Any -import collections - -class CaseInsensitiveDict(collections.MutableMapping): - def __init__(self, data=..., **kwargs) -> None: ... - def __setitem__(self, key, value): ... - def __getitem__(self, key): ... - def __delitem__(self, key): ... - def __iter__(self): ... - def __len__(self): ... - def lower_items(self): ... - def __eq__(self, other): ... - def copy(self): ... - -class LookupDict(dict): - name = ... # type: Any - def __init__(self, name=...) -> None: ... - def __getitem__(self, key): ... - def get(self, key, default=...): ... diff --git a/typeshed/2.7/requests/utils.pyi b/typeshed/2.7/requests/utils.pyi deleted file mode 100644 index 945277afc..000000000 --- a/typeshed/2.7/requests/utils.pyi +++ /dev/null @@ -1,52 +0,0 @@ -# Stubs for requests.utils (Python 3) - -from typing import Any -from . import compat -from . import cookies -from . import structures -from . import exceptions - -OrderedDict = compat.OrderedDict -RequestsCookieJar = cookies.RequestsCookieJar -cookiejar_from_dict = cookies.cookiejar_from_dict -CaseInsensitiveDict = structures.CaseInsensitiveDict -InvalidURL = exceptions.InvalidURL - -NETRC_FILES = ... # type: Any -DEFAULT_CA_BUNDLE_PATH = ... # type: Any - -def dict_to_sequence(d): ... -def super_len(o): ... -def get_netrc_auth(url): ... -def guess_filename(obj): ... -def from_key_val_list(value): ... -def to_key_val_list(value): ... -def parse_list_header(value): ... -def parse_dict_header(value): ... -def unquote_header_value(value, is_filename=...): ... -def dict_from_cookiejar(cj): ... -def add_dict_to_cookiejar(cj, cookie_dict): ... -def get_encodings_from_content(content): ... -def get_encoding_from_headers(headers): ... -def stream_decode_response_unicode(iterator, r): ... -def iter_slices(string, slice_length): ... -def get_unicode_from_response(r): ... - -UNRESERVED_SET = ... # type: Any - -def unquote_unreserved(uri): ... -def requote_uri(uri): ... -def address_in_network(ip, net): ... -def dotted_netmask(mask): ... -def is_ipv4_address(string_ip): ... -def is_valid_cidr(string_network): ... -def should_bypass_proxies(url): ... -def get_environ_proxies(url): ... -def default_user_agent(name=...): ... -def default_headers(): ... -def parse_header_links(value): ... -def guess_json_utf(data): ... -def prepend_scheme_if_needed(url, new_scheme): ... -def get_auth_from_url(url): ... -def to_native_string(string, encoding=...): ... -def urldefragauth(url): ... diff --git a/typeshed/2.7/subprocess.pyi b/typeshed/2.7/subprocess.pyi deleted file mode 100644 index 0cb55fa93..000000000 --- a/typeshed/2.7/subprocess.pyi +++ /dev/null @@ -1,111 +0,0 @@ -# Stubs for subprocess - -# Based on http://docs.python.org/2/library/subprocess.html and Python 3 stub - -from typing import (Sequence, Any, AnyStr, Mapping, Callable, Text, Tuple, IO, Union, - Optional) - -_FILE = Union[int, IO[Any]] - -# Same args as Popen.__init__ -def call(args: Union[str, Sequence[str]], - bufsize: int = ..., - executable: str = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: str = ..., - env: Mapping[str, str] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ...) -> int: ... - -def check_call(args: Union[Text, Sequence[Text]], - bufsize: int = ..., - executable: str = ..., - stdin: _FILE = ..., - stdout: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: str = ..., - env: Mapping[str, str] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ...) -> int: ... - -# Same args as Popen.__init__ except for stdout -def check_output(args: Union[Text, Sequence[Text]], - bufsize: int = ..., - executable: str = ..., - stdin: _FILE = ..., - stderr: _FILE = ..., - preexec_fn: Callable[[], Any] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: str = ..., - env: Mapping[str, str] = ..., - universal_newlines: bool = ..., - startupinfo: Any = ..., - creationflags: int = ...) -> str: ... - -PIPE = ... # type: int -STDOUT = ... # type: int - -class CalledProcessError(Exception): - returncode = 0 - cmd = ... # type: str - output = ... # type: str # May be None - - def __init__(self, returncode: int, cmd: str, output: Optional[str] = ...) -> None: ... - -class Popen: - stdin = ... # type: Optional[IO[Any]] - stdout = ... # type: Optional[IO[Any]] - stderr = ... # type: Optional[IO[Any]] - pid = 0 - returncode = 0 - - def __init__(self, - args: Union[str, Sequence[str]], - bufsize: int = ..., - executable: Optional[str] = ..., - stdin: Optional[_FILE] = ..., - stdout: Optional[_FILE] = ..., - stderr: Optional[_FILE] = ..., - preexec_fn: Optional[Callable[[], Any]] = ..., - close_fds: bool = ..., - shell: bool = ..., - cwd: Optional[Union[str, Text]] = ..., - env: Optional[Union[Mapping[str, str], Mapping[Text, Text]]] = ..., - universal_newlines: bool = ..., - startupinfo: Optional[Any] = ..., - creationflags: int = ...) -> None: ... - - def poll(self) -> int: ... - def wait(self) -> int: ... - # Return str/bytes - def communicate(self, input: Union[str, unicode] = ...) -> Tuple[str, str]: ... - def send_signal(self, signal: int) -> None: ... - def terminate(self) -> None: ... - def kill(self) -> None: ... - def __enter__(self) -> 'Popen': ... - def __exit__(self, type, value, traceback) -> bool: ... - -def getstatusoutput(cmd: str) -> Tuple[int, str]: ... -def getoutput(cmd: str) -> str: ... - -# Windows-only: STARTUPINFO etc. - -STD_INPUT_HANDLE = ... # type: Any -STD_OUTPUT_HANDLE = ... # type: Any -STD_ERROR_HANDLE = ... # type: Any -SW_HIDE = ... # type: Any -STARTF_USESTDHANDLES = ... # type: Any -STARTF_USESHOWWINDOW = ... # type: Any -CREATE_NEW_CONSOLE = ... # type: Any -CREATE_NEW_PROCESS_GROUP = ... # type: Any diff --git a/typeshed/2.7/typing.pyi b/typeshed/2.7/typing.pyi deleted file mode 100644 index a73969a2f..000000000 --- a/typeshed/2.7/typing.pyi +++ /dev/null @@ -1,344 +0,0 @@ -# Stubs for typing (Python 2.7) - -from abc import abstractmethod, ABCMeta - -# Definitions of special type checking related constructs. Their definition -# are not used, so their value does not matter. - -cast = object() -overload = object() -Any = object() -TypeVar = object() -Generic = object() -Tuple = object() -Callable = object() -Type = object() -builtinclass = object() -_promote = object() -NamedTuple = object() -NewType = object() - -# Type aliases - -class TypeAlias: - # Class for defining generic aliases for library types. - def __init__(self, target_type: type) -> None: ... - def __getitem__(self, typeargs: Any) -> Any: ... - -Union = TypeAlias(object) -Optional = TypeAlias(object) -List = TypeAlias(object) -Dict = TypeAlias(object) -DefaultDict = TypeAlias(object) -Set = TypeAlias(object) - -# Predefined type variables. -AnyStr = TypeVar('AnyStr', str, unicode) - -# Abstract base classes. - -# These type variables are used by the container types. -_T = TypeVar('_T') -_S = TypeVar('_S') -_KT = TypeVar('_KT') # Key type. -_VT = TypeVar('_VT') # Value type. -_T_co = TypeVar('_T_co', covariant=True) # Any type covariant containers. -_V_co = TypeVar('_V_co', covariant=True) # Any type covariant containers. -_KT_co = TypeVar('_KT_co', covariant=True) # Key type covariant containers. -_VT_co = TypeVar('_VT_co', covariant=True) # Value type covariant containers. -_T_contra = TypeVar('_T_contra', contravariant=True) # Ditto contravariant. - -class SupportsInt(metaclass=ABCMeta): - @abstractmethod - def __int__(self) -> int: ... - -class SupportsFloat(metaclass=ABCMeta): - @abstractmethod - def __float__(self) -> float: ... - -class SupportsAbs(Generic[_T]): - @abstractmethod - def __abs__(self) -> _T: ... - -class SupportsRound(Generic[_T]): - @abstractmethod - def __round__(self, ndigits: int = ...) -> _T: ... - -class Reversible(Generic[_T_co]): - @abstractmethod - def __reversed__(self) -> Iterator[_T_co]: ... - -class Sized(metaclass=ABCMeta): - @abstractmethod - def __len__(self) -> int: ... - -class Iterable(Generic[_T_co]): - @abstractmethod - def __iter__(self) -> Iterator[_T_co]: ... - -class Iterator(Iterable[_T_co], Generic[_T_co]): - @abstractmethod - def next(self) -> _T_co: ... - -class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]): - @abstractmethod - def next(self) -> _T_co:... - - @abstractmethod - def send(self, value: _T_contra) -> _T_co:... - - @abstractmethod - def throw(self, typ: BaseException, val: Any = None, tb: Any = None) -> None:... - - @abstractmethod - def close(self) -> None:... - -class Container(Generic[_T_co]): - @abstractmethod - def __contains__(self, x: object) -> bool: ... - -class Sequence(Iterable[_T_co], Container[_T_co], Sized, Reversible[_T_co], Generic[_T_co]): - @overload - @abstractmethod - def __getitem__(self, i: int) -> _T_co: ... - @overload - @abstractmethod - def __getitem__(self, s: slice) -> Sequence[_T_co]: ... - # Mixin methods - def index(self, x: Any) -> int: ... - def count(self, x: Any) -> int: ... - def __contains__(self, x: object) -> bool: ... - def __iter__(self) -> Iterator[_T_co]: ... - def __reversed__(self) -> Iterator[_T_co]: ... - -class MutableSequence(Sequence[_T], Generic[_T]): - @abstractmethod - def insert(self, index: int, object: _T) -> None: ... - @overload - @abstractmethod - def __setitem__(self, i: int, o: _T) -> None: ... - @overload - @abstractmethod - def __setitem__(self, s: slice, o: Iterable[_T]) -> None: ... - @abstractmethod - def __delitem__(self, i: Union[int, slice]) -> None: ... - # Mixin methods - def append(self, object: _T) -> None: ... - def extend(self, iterable: Iterable[_T]) -> None: ... - def reverse(self) -> None: ... - def pop(self, index: int = ...) -> _T: ... - def remove(self, object: _T) -> None: ... - def __iadd__(self, x: Iterable[_T]) -> MutableSequence[_T]: ... - -class AbstractSet(Sized, Iterable[_T_co], Container[_T_co], Generic[_T_co]): - @abstractmethod - def __contains__(self, x: object) -> bool: ... - # Mixin methods - def __le__(self, s: AbstractSet[Any]) -> bool: ... - def __lt__(self, s: AbstractSet[Any]) -> bool: ... - def __gt__(self, s: AbstractSet[Any]) -> bool: ... - def __ge__(self, s: AbstractSet[Any]) -> bool: ... - def __and__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __or__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ... - def __sub__(self, s: AbstractSet[Any]) -> AbstractSet[_T_co]: ... - def __xor__(self, s: AbstractSet[_T]) -> AbstractSet[Union[_T_co, _T]]: ... - # TODO: argument can be any container? - def isdisjoint(self, s: AbstractSet[Any]) -> bool: ... - -class FrozenSet(AbstractSet[_T], Generic[_T]): ... - -class MutableSet(AbstractSet[_T], Generic[_T]): - @abstractmethod - def add(self, x: _T) -> None: ... - @abstractmethod - def discard(self, x: _T) -> None: ... - # Mixin methods - def clear(self) -> None: ... - def pop(self) -> _T: ... - def remove(self, element: _T) -> None: ... - def __ior__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ... - def __iand__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ... - def __ixor__(self, s: AbstractSet[_S]) -> MutableSet[Union[_T, _S]]: ... - def __isub__(self, s: AbstractSet[Any]) -> MutableSet[_T]: ... - -class MappingView(Sized): - def __len__(self) -> int: ... - -class ItemsView(AbstractSet[Tuple[_KT_co, _VT_co]], MappingView, Generic[_KT_co, _VT_co]): - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[Tuple[_KT_co, _VT_co]]: ... - -class KeysView(AbstractSet[_KT_co], MappingView, Generic[_KT_co]): - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_KT_co]: ... - -class ValuesView(MappingView, Iterable[_VT_co], Generic[_VT_co]): - def __contains__(self, o: object) -> bool: ... - def __iter__(self) -> Iterator[_VT_co]: ... - -class Mapping(Sized, Iterable[_KT], Container[_KT], Generic[_KT, _VT]): - @abstractmethod - def __getitem__(self, k: _KT) -> _VT: ... - # Mixin methods - def get(self, k: _KT, default: _VT = ...) -> _VT: ... - def keys(self) -> list[_KT]: ... - def values(self) -> list[_VT]: ... - def items(self) -> list[Tuple[_KT, _VT]]: ... - def iterkeys(self) -> Iterator[_KT]: ... - def itervalues(self) -> Iterator[_VT]: ... - def iteritems(self) -> Iterator[Tuple[_KT, _VT]]: ... - def __contains__(self, o: object) -> bool: ... - -class MutableMapping(Mapping[_KT, _VT], Generic[_KT, _VT]): - @abstractmethod - def __setitem__(self, k: _KT, v: _VT) -> None: ... - @abstractmethod - def __delitem__(self, v: _KT) -> None: ... - - def clear(self) -> None: ... - def pop(self, k: _KT, default: _VT = ...) -> _VT: ... - def popitem(self) -> Tuple[_KT, _VT]: ... - def setdefault(self, k: _KT, default: _VT = ...) -> _VT: ... - @overload - def update(self, m: Mapping[_KT, _VT], **kwargs: _VT) -> None: ... - @overload - def update(self, m: Iterable[Tuple[_KT, _VT]], **kwargs: _VT) -> None: ... - -Text = unicode - -TYPE_CHECKING = True - -class IO(Iterable[AnyStr], Generic[AnyStr]): - # TODO detach - # TODO use abstract properties - @property - def mode(self) -> str: ... - @property - def name(self) -> str: ... - @abstractmethod - def close(self) -> None: ... - @property - def closed(self) -> bool: ... - @abstractmethod - def fileno(self) -> int: ... - @abstractmethod - def flush(self) -> None: ... - @abstractmethod - def isatty(self) -> bool: ... - # TODO what if n is None? - @abstractmethod - def read(self, n: int = ...) -> AnyStr: ... - @abstractmethod - def readable(self) -> bool: ... - @abstractmethod - def readline(self, limit: int = ...) -> AnyStr: ... - @abstractmethod - def readlines(self, hint: int = ...) -> list[AnyStr]: ... - @abstractmethod - def seek(self, offset: int, whence: int = ...) -> None: ... - @abstractmethod - def seekable(self) -> bool: ... - @abstractmethod - def tell(self) -> int: ... - @abstractmethod - def truncate(self, size: int = ...) -> Optional[int]: ... - @abstractmethod - def writable(self) -> bool: ... - # TODO buffer objects - @abstractmethod - def write(self, s: Union[str, Text]) -> None: ... - @abstractmethod - def writelines(self, lines: Iterable[AnyStr]) -> None: ... - - @abstractmethod - def __iter__(self) -> Iterator[AnyStr]: ... - @abstractmethod - def __enter__(self) -> 'IO[AnyStr]': ... - @abstractmethod - def __exit__(self, t: type, value: Any, traceback: Any) -> bool: ... - -class BinaryIO(IO[str]): - # TODO readinto - # TODO read1? - # TODO peek? - @abstractmethod - def __enter__(self) -> BinaryIO: ... - -class TextIO(IO[unicode]): - # TODO use abstractproperty - @property - def buffer(self) -> BinaryIO: ... - @property - def encoding(self) -> str: ... - @property - def errors(self) -> str: ... - @property - def line_buffering(self) -> bool: ... - @property - def newlines(self) -> Any: ... # None, str or tuple - @abstractmethod - def __enter__(self) -> TextIO: ... - -class Match(Generic[AnyStr]): - pos = 0 - endpos = 0 - lastindex = 0 - lastgroup = ... # type: AnyStr - string = ... # type: AnyStr - - # The regular expression object whose match() or search() method produced - # this match instance. - re = ... # type: 'Pattern[AnyStr]' - - def expand(self, template: AnyStr) -> AnyStr: ... - - @overload - def group(self, group1: int = ...) -> AnyStr: ... - @overload - def group(self, group1: str) -> AnyStr: ... - @overload - def group(self, group1: int, group2: int, - *groups: int) -> Sequence[AnyStr]: ... - @overload - def group(self, group1: str, group2: str, - *groups: str) -> Sequence[AnyStr]: ... - - def groups(self, default: AnyStr = ...) -> Sequence[AnyStr]: ... - def groupdict(self, default: AnyStr = ...) -> dict[str, AnyStr]: ... - def start(self, group: Union[int, str] = ...) -> int: ... - def end(self, group: Union[int, str] = ...) -> int: ... - def span(self, group: Union[int, str] = ...) -> Tuple[int, int]: ... - -class Pattern(Generic[AnyStr]): - flags = 0 - groupindex = 0 - groups = 0 - pattern = ... # type: AnyStr - - def search(self, string: Union[str, Text], pos: int = ..., - endpos: int = ...) -> Match[AnyStr]: ... - def match(self, string: Union[str, Text], pos: int = ..., - endpos: int = ...) -> Match[AnyStr]: ... - def split(self, string: AnyStr, maxsplit: int = ...) -> list[AnyStr]: ... - def findall(self, string: AnyStr, pos: int = ..., - endpos: int = ...) -> list[Any]: ... - def finditer(self, string: AnyStr, pos: int = ..., - endpos: int = ...) -> Iterator[Match[AnyStr]]: ... - - @overload - def sub(self, repl: AnyStr, string: AnyStr, - count: int = ...) -> AnyStr: ... - @overload - def sub(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, - count: int = ...) -> AnyStr: ... - - @overload - def subn(self, repl: AnyStr, string: AnyStr, - count: int = ...) -> Tuple[AnyStr, int]: ... - @overload - def subn(self, repl: Callable[[Match[AnyStr]], AnyStr], string: AnyStr, - count: int = ...) -> Tuple[AnyStr, int]: ... - -# Functions - -def get_type_hints(obj: Callable) -> dict[str, Any]: ... diff --git a/typeshed/2.7/urllib.pyi b/typeshed/2.7/urllib.pyi index cc9ba80e9..2ec98ab63 100644 --- a/typeshed/2.7/urllib.pyi +++ b/typeshed/2.7/urllib.pyi @@ -1,9 +1,9 @@ -# Stubs for urllib (Python 2) -# NOTE: This dynamically typed stub was originally automatically generated by stubgen. +from typing import overload, Text, Any, Mapping, Union, Tuple, Sequence, IO -from typing import Any, AnyStr, Mapping, Union, Tuple, Sequence, IO - -def url2pathname(pathname: AnyStr) -> AnyStr: ... +@overload +def url2pathname(pathname: str) -> str: ... +@overload +def url2pathname(pathname: unicode) -> str: ... def pathname2url(pathname: str) -> str: ... def urlopen(url: str, data=..., proxies: Mapping[str, str] = ..., context=...) -> IO[Any]: ... def urlretrieve(url, filename=..., reporthook=..., data=..., context=...): ... diff --git a/typeshed/2.7/urlparse.pyi b/typeshed/2.7/urlparse.pyi index 58ae6d674..ff763b0fe 100644 --- a/typeshed/2.7/urlparse.pyi +++ b/typeshed/2.7/urlparse.pyi @@ -1,6 +1,6 @@ # Stubs for urlparse (Python 2) -from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload +from typing import AnyStr, Dict, List, NamedTuple, Tuple, Sequence, Union, overload, Text uses_relative = [] # type: List[str] uses_netloc = [] # type: List[str] diff --git a/typeshed/2.7/cachecontrol/__init__.pyi b/typeshed/2and3/cachecontrol/__init__.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/__init__.pyi rename to typeshed/2and3/cachecontrol/__init__.pyi diff --git a/typeshed/2.7/cachecontrol/adapter.pyi b/typeshed/2and3/cachecontrol/adapter.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/adapter.pyi rename to typeshed/2and3/cachecontrol/adapter.pyi diff --git a/typeshed/2.7/cachecontrol/cache.pyi b/typeshed/2and3/cachecontrol/cache.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/cache.pyi rename to typeshed/2and3/cachecontrol/cache.pyi diff --git a/typeshed/2.7/cachecontrol/caches/__init__.pyi b/typeshed/2and3/cachecontrol/caches/__init__.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/caches/__init__.pyi rename to typeshed/2and3/cachecontrol/caches/__init__.pyi diff --git a/typeshed/2.7/cachecontrol/caches/file_cache.pyi b/typeshed/2and3/cachecontrol/caches/file_cache.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/caches/file_cache.pyi rename to typeshed/2and3/cachecontrol/caches/file_cache.pyi diff --git a/typeshed/2.7/cachecontrol/compat.pyi b/typeshed/2and3/cachecontrol/compat.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/compat.pyi rename to typeshed/2and3/cachecontrol/compat.pyi diff --git a/typeshed/2.7/cachecontrol/controller.pyi b/typeshed/2and3/cachecontrol/controller.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/controller.pyi rename to typeshed/2and3/cachecontrol/controller.pyi diff --git a/typeshed/2.7/cachecontrol/filewrapper.pyi b/typeshed/2and3/cachecontrol/filewrapper.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/filewrapper.pyi rename to typeshed/2and3/cachecontrol/filewrapper.pyi diff --git a/typeshed/2.7/cachecontrol/serialize.pyi b/typeshed/2and3/cachecontrol/serialize.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/serialize.pyi rename to typeshed/2and3/cachecontrol/serialize.pyi diff --git a/typeshed/2.7/cachecontrol/wrapper.pyi b/typeshed/2and3/cachecontrol/wrapper.pyi similarity index 100% rename from typeshed/2.7/cachecontrol/wrapper.pyi rename to typeshed/2and3/cachecontrol/wrapper.pyi diff --git a/typeshed/2and3/mistune.pyi b/typeshed/2and3/mistune.pyi new file mode 100644 index 000000000..d267d9216 --- /dev/null +++ b/typeshed/2and3/mistune.pyi @@ -0,0 +1,271 @@ +__author__ = "Aleksandr Slepchenkov" +__email__ = "Sl.aleksandr28@gmail.com" + +from typing import Any, Optional, Pattern, List, Text, Tuple, Dict, Match, Type, Sequence, Iterable + +Tokens = List[Dict[Text, Any]] +# There are too much levels of optional unions of lists of text in cell and align 385 and 396 lines in mistune + + +def escape(text: Text, quote: bool = ..., smart_amp: bool = ...) -> Text: ... + + +class BlockGrammar: + def_links = ... # type: Pattern + def_footnotes = ... # type: Pattern + newline = ... # type: Pattern + block_code = ... # type: Pattern + fences = ... # type: Pattern + hrule = ... # type: Pattern + heading = ... # type: Pattern + lheading = ... # type: Pattern + block_quote = ... # type: Pattern + list_block = ... # type: Pattern + list_item = ... # type: Pattern + list_bullet = ... # type: Pattern + paragraph = ... # type: Pattern + block_html = ... # type: Pattern + table = ... # type: Pattern + nptable = ... # type: Pattern + text = ... # type: Pattern + + +class BlockLexer: + grammar_class = ... # type: Type[BlockGrammar] + default_rules = ... # type: List[Text] + list_rules = ... # type: Tuple[Text] + footnote_rules = ... # type: Tuple[Text] + tokens = ... # type: Tokens + def_links = ... # type: Dict[Text, Dict[Text, Text]] + def_footnotes = ... # type: Dict[Text, int] + rules = ... # type: BlockGrammar + + def __init__(self, rules: Optional[BlockGrammar] = ..., **kwargs) -> None: ... + + def __call__(self, text: Text, rules: Optional[Sequence[Text]] = ...) -> Tokens: ... + + def parse(self, text: Text, rules: Optional[Sequence[Text]] = ...) -> Tokens: ... + + def parse_newline(self, m: Match) -> None: ... + + def parse_block_code(self, m: Match) -> None: ... + + def parse_fences(self, m: Match) -> None: ... + + def parse_heading(self, m: Match) -> None: ... + + def parse_lheading(self, m: Match) -> None: ... + + def parse_hrule(self, m: Match) -> None: ... + + def parse_list_block(self, m: Match) -> None: ... + + def parse_block_quote(self, m: Match) -> None: ... + + def parse_def_links(self, m: Match) -> None: ... + + def parse_def_footnotes(self, m: Match) -> None: ... + + def parse_table(self, m: Match) -> None: ... + + def parse_nptable(self, m: Match) -> None: ... + + def parse_block_html(self, m: Match) -> None: ... + + def parse_paragraph(self, m: Match) -> None: ... + + def parse_text(self, m: Match) -> None: ... + + +class InlineGrammar: + escape = ... # type: Pattern + inline_html = ... # type: Pattern + autolink = ... # type: Pattern + link = ... # type: Pattern + reflink = ... # type: Pattern + nolink = ... # type: Pattern + url = ... # type: Pattern + double_emphasis = ... # type: Pattern + emphasis = ... # type: Pattern + code = ... # type: Pattern + linebreak = ... # type: Pattern + strikethrough = ... # type: Pattern + footnote = ... # type: Pattern + text = ... # type: Pattern + + def hard_wrap(self) -> None: ... + + +class InlineLexer: + grammar_class = ... # type: Type[InlineGrammar] + default_rules = ... # type: List[Text] + inline_html_rules = ... # type: List[Text] + renderer = ... # type: Renderer + links = ... # type: Dict[Any, Dict] + footnotes = ... # type: Dict[Text, int] + footnote_index = ... # type: int + _in_link = ... # type: bool + _in_footnote = ... # type: bool + _parse_inline_html = ... # type: bool + rules = ... # type: InlineGrammar + + def __init__(self, renderer: Renderer, rules: Optional[InlineGrammar] = ..., **kwargs) -> None: ... + + def __call__(self, text: Text, rules: Optional[Sequence[Text]] = ...) -> Text: ... + + def setup(self, links: Optional[Dict[Any, Dict]], footnotes: Optional[Dict[Text, int]]) -> None: ... + + line_match = ... # type: Match + line_started = ... # type: bool + + def output(self, text: Text, rules: Optional[Sequence[Text]] = ...) -> Text: ... + + def output_escape(self, m: Match) -> Text: ... + + def output_autolink(self, m: Match) -> Text: ... + + def output_url(self, m: Match) -> Text: ... + + def output_inline_html(self, m: Match) -> Text: ... + + def output_footnote(self, m: Match) -> Optional[Text]: ... + + def output_link(self, m: Match) -> Text: ... + + def output_reflink(self, m: Match) -> Optional[Text]: ... + + def output_nolink(self, m: Match) -> Optional[Text]: ... + + def output_double_emphasis(self, m: Match) -> Text: ... + + def output_emphasis(self, m: Match) -> Text: ... + + def output_code(self, m: Match) -> Text: ... + + def output_linebreak(self, m: Match) -> Text: ... + + def output_strikethrough(self, m: Match) -> Text: ... + + def output_text(self, m: Match) -> Text: ... + + +class Renderer: + options = ... # type: Dict + + def __init__(self, **kwargs) -> None: ... + + def placeholder(self) -> Text: ... + + def block_code(self, code: Text, + lang: Any = ...) -> Text: ... # It seems that lang should be string, however other types are valid as well + + def block_quote(self, text: Text) -> Text: ... + + def block_html(self, html: Text) -> Text: ... + + def header(self, text: Text, level: int, raw: Optional[Text] = ...) -> Text: ... + + def hrule(self) -> Text: ... + + def list(self, body: Any, + ordered: bool = ...) -> Text: ... # body - same reason as for lang above, and for other Any in this class + + def list_item(self, text: Any) -> Text: ... + + def paragraph(self, text: Text) -> Text: ... + + def table(self, header: Any, body: Any) -> Text: ... + + def table_row(self, content: Any) -> Text: ... + + def table_cell(self, content: Any, **flags) -> Text: ... + + def double_emphasis(self, text: Any) -> Text: ... + + def emphasis(self, text: Any) -> Text: ... + + def codespan(self, text: Text) -> Text: ... + + def linebreak(self) -> Text: ... + + def strikethrough(self, text: Any) -> Text: ... + + def text(self, text: Any) -> Text: ... + + def escape(self, text: Any) -> Text: ... + + def autolink(self, link: Any, is_email: bool = ...) -> Text: ... + + def link(self, link: Any, title: Any, text: Any) -> Text: ... + + def image(self, src: Any, title: Any, text: Any) -> Text: ... + + def inline_html(self, html: Any) -> Text: ... + + def newline(self) -> Text: ... + + def footnote_ref(self, key: Any, index: int) -> Text: ... + + def footnote_item(self, key: Any, text: Text) -> Text: ... + + def footnotes(self, text: Any) -> Text: ... + + +class Markdown: + renderer = ... # type: Renderer + inline = ... # type: InlineLexer + block = ... # type: BlockLexer + footnotes = ... # type: List[Dict[Text, Any]] + tokens = ... # type: Tokens + + def __init__(self, renderer: Optional[Renderer] = ..., inline: Optional[InlineLexer] = ..., + block: Optional[BlockLexer] = ..., **kwargs) -> None: ... + + def __call__(self, text: Text) -> Text: ... + + def render(self, text: Text) -> Text: ... + + def parse(self, text: Text) -> Text: ... + + token = ... # type: Dict[Text, Any] + + def pop(self) -> Optional[Dict[Text, Any]]: ... + + def peek(self) -> Optional[Dict[Text, Any]]: ... + + def output(self, text: Text, rules: Optional[Sequence[Text]] = ...): ... + + def tok(self) -> Text: ... + + def tok_text(self) -> Text: ... + + def output_newline(self) -> Text: ... + + def output_hrule(self) -> Text: ... + + def output_heading(self) -> Text: ... + + def output_code(self) -> Text: ... + + def output_table(self) -> Text: ... + + def output_block_quote(self) -> Text: ... + + def output_list(self) -> Text: ... + + def output_list_item(self) -> Text: ... + + def output_loose_item(self) -> Text: ... + + def output_footnote(self) -> Text: ... + + def output_close_html(self) -> Text: ... + + def output_open_html(self) -> Text: ... + + def output_paragraph(self) -> Text: ... + + def output_text(self) -> Text: ... + + +def markdown(text: Text, escape: bool = ..., **kwargs) -> Text: ... \ No newline at end of file diff --git a/typeshed/2.7/rdflib/__init__.pyi b/typeshed/2and3/rdflib/__init__.pyi similarity index 100% rename from typeshed/2.7/rdflib/__init__.pyi rename to typeshed/2and3/rdflib/__init__.pyi diff --git a/typeshed/2.7/rdflib/events.pyi b/typeshed/2and3/rdflib/events.pyi similarity index 100% rename from typeshed/2.7/rdflib/events.pyi rename to typeshed/2and3/rdflib/events.pyi diff --git a/typeshed/2.7/rdflib/exceptions.pyi b/typeshed/2and3/rdflib/exceptions.pyi similarity index 100% rename from typeshed/2.7/rdflib/exceptions.pyi rename to typeshed/2and3/rdflib/exceptions.pyi diff --git a/typeshed/2.7/rdflib/graph.pyi b/typeshed/2and3/rdflib/graph.pyi similarity index 92% rename from typeshed/2.7/rdflib/graph.pyi rename to typeshed/2and3/rdflib/graph.pyi index 9b5c62a6e..2cfc6f450 100644 --- a/typeshed/2.7/rdflib/graph.pyi +++ b/typeshed/2and3/rdflib/graph.pyi @@ -2,8 +2,8 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any, AnyStr, Union, IO, Tuple, Iterator -from StringIO import StringIO as BytesIO +from typing import Any, AnyStr, Dict, Union, IO, Tuple, Iterator, Text +from io import StringIO as BytesIO from rdflib.term import Node, URIRef from rdflib.store import Store from rdflib.namespace import NamespaceManager @@ -26,7 +26,7 @@ class Graph(Node): def add(self, __tuple_arg_2: Tuple[Node, Node, Node]) -> None: ... def addN(self, quads): ... def remove(self, __tuple_arg_2: Tuple[Union[AnyStr, URIRef], AnyStr, Union[AnyStr, URIRef]]) -> None: ... - def triples(self, __tuple_arg_2: Tuple[Union[AnyStr, URIRef], AnyStr, Union[AnyStr, URIRef]]) -> Iterator[Tuple[AnyStr, AnyStr, AnyStr]]: ... + def triples(self, __tuple_arg_2: Tuple[Union[AnyStr, URIRef, None], Union[AnyStr, None], Union[AnyStr, URIRef, None]]) -> Iterator[Tuple[AnyStr, AnyStr, AnyStr]]: ... def __getitem__(self, item): ... def __len__(self): ... def __iter__(self): ... @@ -69,10 +69,10 @@ class Graph(Node): def bind(self, prefix: str, namespace: str, override: bool=True) -> None: ... def namespaces(self): ... def absolutize(self, uri, defrag=1): ... - def serialize(self, destination: Union[str, IO[Any]]=None, format: AnyStr='', base: str=None, encoding: str=None, **args) -> Union[bytes, None]: ... + def serialize(self, destination: Union[Text, IO[Any]]=None, format: Text='', base: str=None, encoding: str=None, **args) -> Union[bytes, None]: ... def parse(self, source: str = None, publicID: str = None, - format: Union[str, unicode] = None, - location: Union[str, unicode] = None, file: IO[Any] = None, + format: Text = None, + location: Text = None, file: IO[Any] = None, data: str = None, **args): ... def load(self, source, publicID=None, format=''): ... def query(self, query_object, processor: str = '', result: str = '', initNs: Dict = None, initBindings: Dict = None, use_store_provided: bool = True, **kwargs) -> Result: ... diff --git a/typeshed/2.7/rdflib/namespace.pyi b/typeshed/2and3/rdflib/namespace.pyi similarity index 90% rename from typeshed/2.7/rdflib/namespace.pyi rename to typeshed/2and3/rdflib/namespace.pyi index 01197c745..2a0a6816d 100644 --- a/typeshed/2.7/rdflib/namespace.pyi +++ b/typeshed/2and3/rdflib/namespace.pyi @@ -2,9 +2,9 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any, Tuple, Union +from typing import Any, Tuple, Union, Text -class Namespace(unicode): +class Namespace(Text): __doc__ = ... # type: Any def __new__(cls, value): ... @property @@ -13,7 +13,7 @@ class Namespace(unicode): def __getitem__(self, key, default=None): ... def __getattr__(self, name): ... -class URIPattern(unicode): +class URIPattern(Text): __doc__ = ... # type: Any def __new__(cls, value): ... def __mod__(self, *args, **kwargs): ... @@ -57,4 +57,4 @@ def is_ncname(name): ... XMLNS = ... # type: Any -def split_uri(uri: Union[str, unicode]) -> Tuple[str, str]: ... +def split_uri(uri: Text) -> Tuple[str, str]: ... diff --git a/typeshed/2.7/rdflib/parser.pyi b/typeshed/2and3/rdflib/parser.pyi similarity index 84% rename from typeshed/2.7/rdflib/parser.pyi rename to typeshed/2and3/rdflib/parser.pyi index 3ff074d8c..fa1ec9a74 100644 --- a/typeshed/2.7/rdflib/parser.pyi +++ b/typeshed/2and3/rdflib/parser.pyi @@ -3,7 +3,7 @@ # NOTE: This dynamically typed stub was automatically generated by stubgen. from typing import Any -from StringIO import StringIO as BytesIO +from io import StringIO as BytesIO class Parser: def __init__(self): ... diff --git a/typeshed/2.7/rdflib/plugin.pyi b/typeshed/2and3/rdflib/plugin.pyi similarity index 100% rename from typeshed/2.7/rdflib/plugin.pyi rename to typeshed/2and3/rdflib/plugin.pyi diff --git a/typeshed/2.7/rdflib/plugins/__init__.pyi b/typeshed/2and3/rdflib/plugins/__init__.pyi similarity index 100% rename from typeshed/2.7/rdflib/plugins/__init__.pyi rename to typeshed/2and3/rdflib/plugins/__init__.pyi diff --git a/typeshed/2.7/rdflib/plugins/parsers/__init__.pyi b/typeshed/2and3/rdflib/plugins/parsers/__init__.pyi similarity index 100% rename from typeshed/2.7/rdflib/plugins/parsers/__init__.pyi rename to typeshed/2and3/rdflib/plugins/parsers/__init__.pyi diff --git a/typeshed/2.7/rdflib/plugins/parsers/notation3.pyi b/typeshed/2and3/rdflib/plugins/parsers/notation3.pyi similarity index 100% rename from typeshed/2.7/rdflib/plugins/parsers/notation3.pyi rename to typeshed/2and3/rdflib/plugins/parsers/notation3.pyi diff --git a/typeshed/2.7/rdflib/query.pyi b/typeshed/2and3/rdflib/query.pyi similarity index 97% rename from typeshed/2.7/rdflib/query.pyi rename to typeshed/2and3/rdflib/query.pyi index db002b8b0..fad3c3770 100644 --- a/typeshed/2.7/rdflib/query.pyi +++ b/typeshed/2and3/rdflib/query.pyi @@ -3,7 +3,7 @@ # NOTE: This dynamically typed stub was automatically generated by stubgen. from typing import Any -from StringIO import StringIO as BytesIO +from io import StringIO as BytesIO import collections class Processor: diff --git a/typeshed/2.7/rdflib/serializer.pyi b/typeshed/2and3/rdflib/serializer.pyi similarity index 100% rename from typeshed/2.7/rdflib/serializer.pyi rename to typeshed/2and3/rdflib/serializer.pyi diff --git a/typeshed/2.7/rdflib/store.pyi b/typeshed/2and3/rdflib/store.pyi similarity index 97% rename from typeshed/2.7/rdflib/store.pyi rename to typeshed/2and3/rdflib/store.pyi index 4a98a44b0..6886321b0 100644 --- a/typeshed/2.7/rdflib/store.pyi +++ b/typeshed/2and3/rdflib/store.pyi @@ -4,7 +4,7 @@ from typing import Any from rdflib.events import Event -from cStringIO import StringIO as BytesIO +from io import StringIO as BytesIO class StoreCreatedEvent(Event): ... class TripleAddedEvent(Event): ... diff --git a/typeshed/2.7/rdflib/term.pyi b/typeshed/2and3/rdflib/term.pyi similarity index 97% rename from typeshed/2.7/rdflib/term.pyi rename to typeshed/2and3/rdflib/term.pyi index 698218123..0021d14be 100644 --- a/typeshed/2.7/rdflib/term.pyi +++ b/typeshed/2and3/rdflib/term.pyi @@ -2,11 +2,11 @@ # # NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any +from typing import Any, Text class Node: ... -class Identifier(Node, unicode): +class Identifier(Node, Text): def __new__(cls, value): ... def eq(self, other): ... def neq(self, other): ... diff --git a/typeshed/2.7/rdflib/util.pyi b/typeshed/2and3/rdflib/util.pyi similarity index 100% rename from typeshed/2.7/rdflib/util.pyi rename to typeshed/2and3/rdflib/util.pyi diff --git a/typeshed/2.7/ruamel/__init__.py b/typeshed/2and3/ruamel/__init__.py similarity index 100% rename from typeshed/2.7/ruamel/__init__.py rename to typeshed/2and3/ruamel/__init__.py diff --git a/typeshed/2and3/select.pyi b/typeshed/2and3/select.pyi new file mode 100644 index 000000000..094bb916c --- /dev/null +++ b/typeshed/2and3/select.pyi @@ -0,0 +1,137 @@ +import sys +from typing import Any, Optional, Sequence, Tuple, Iterable, List, Union + +# When we have protocols, this should change to a protocol with a fileno method +# See https://docs.python.org/3/c-api/file.html#c.PyObject_AsFileDescriptor +_FileDescriptor = Union[int, Any] + +EPOLLERR: int +EPOLLET: int +EPOLLHUP: int +EPOLLIN: int +EPOLLMSG: int +EPOLLONESHOT: int +EPOLLOUT: int +EPOLLPRI: int +EPOLLRDBAND: int +EPOLLRDNORM: int +EPOLLWRBAND: int +EPOLLWRNORM: int +EPOLL_RDHUP: int +KQ_EV_ADD: int +KQ_EV_CLEAR: int +KQ_EV_DELETE: int +KQ_EV_DISABLE: int +KQ_EV_ENABLE: int +KQ_EV_EOF: int +KQ_EV_ERROR: int +KQ_EV_FLAG1: int +KQ_EV_ONESHOT: int +KQ_EV_SYSFLAGS: int +KQ_FILTER_AIO: int +KQ_FILTER_NETDEV: int +KQ_FILTER_PROC: int +KQ_FILTER_READ: int +KQ_FILTER_SIGNAL: int +KQ_FILTER_TIMER: int +KQ_FILTER_VNODE: int +KQ_FILTER_WRITE: int +KQ_NOTE_ATTRIB: int +KQ_NOTE_CHILD: int +KQ_NOTE_DELETE: int +KQ_NOTE_EXEC: int +KQ_NOTE_EXIT: int +KQ_NOTE_EXTEND: int +KQ_NOTE_FORK: int +KQ_NOTE_LINK: int +KQ_NOTE_LINKDOWN: int +KQ_NOTE_LINKINV: int +KQ_NOTE_LINKUP: int +KQ_NOTE_LOWAT: int +KQ_NOTE_PCTRLMASK: int +KQ_NOTE_PDATAMASK: int +KQ_NOTE_RENAME: int +KQ_NOTE_REVOKE: int +KQ_NOTE_TRACK: int +KQ_NOTE_TRACKERR: int +KQ_NOTE_WRITE: int +PIPE_BUF: int +POLLERR: int +POLLHUP: int +POLLIN: int +POLLMSG: int +POLLNVAL: int +POLLOUT: int +POLLPRI: int +POLLRDBAND: int +POLLRDNORM: int +POLLWRBAND: int +POLLWRNORM: int + +class poll: + def __init__(self) -> None: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... + +def select(rlist: Sequence[Any], wlist: Sequence[Any], xlist: Sequence[Any], + timeout: Optional[float] = ...) -> Tuple[List[Any], + List[Any], + List[Any]]: ... + +if sys.version_info >= (3, 3): + error = OSError +else: + class error(Exception): ... + +# BSD only +class kevent(object): + data: Any + fflags: int + filter: int + flags: int + ident: int + udata: Any + def __init__(self, ident: _FileDescriptor, filter: int = ..., flags: int = ..., fflags: int = ..., data: Any = ..., udata: Any = ...) -> None: ... + +# BSD only +class kqueue(object): + closed: bool + def __init__(self) -> None: ... + def close(self) -> None: ... + def control(self, changelist: Optional[Iterable[kevent]], max_events: int, timeout: float = ...) -> List[kevent]: ... + def fileno(self) -> int: ... + @classmethod + def fromfd(cls, fd: _FileDescriptor) -> kqueue: ... + +# Linux only +class epoll(object): + if sys.version_info >= (3, 3): + def __init__(self, sizehint: int = ..., flags: int = ...) -> None: ... + else: + def __init__(self, sizehint: int = ...) -> None: ... + if sys.version_info >= (3, 4): + def __enter__(self) -> epoll: ... + def __exit__(self, *args: Any) -> None: ... + def close(self) -> None: ... + closed: bool + def fileno(self) -> int: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: float = ..., maxevents: int = ...) -> List[Tuple[int, int]]: ... + @classmethod + def fromfd(cls, fd: _FileDescriptor) -> epoll: ... + +if sys.version_info >= (3, 3): + # Solaris only + class devpoll: + if sys.version_info >= (3, 4): + def close(self) -> None: ... + closed: bool + def fileno(self) -> int: ... + def register(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def modify(self, fd: _FileDescriptor, eventmask: int = ...) -> None: ... + def unregister(self, fd: _FileDescriptor) -> None: ... + def poll(self, timeout: Optional[float] = ...) -> List[Tuple[int, int]]: ... \ No newline at end of file diff --git a/typeshed/2.7/shellescape/__init__.pyi b/typeshed/2and3/shellescape/__init__.pyi similarity index 100% rename from typeshed/2.7/shellescape/__init__.pyi rename to typeshed/2and3/shellescape/__init__.pyi diff --git a/typeshed/2.7/shellescape/main.pyi b/typeshed/2and3/shellescape/main.pyi similarity index 100% rename from typeshed/2.7/shellescape/main.pyi rename to typeshed/2and3/shellescape/main.pyi diff --git a/typeshed/3/avro/__init__.pyi b/typeshed/3/avro/__init__.pyi new file mode 100644 index 000000000..0a82029d3 --- /dev/null +++ b/typeshed/3/avro/__init__.pyi @@ -0,0 +1,10 @@ +# Stubs for avro (Python 3.5) +# +# NOTE: This dynamically typed stub was automatically generated by stubgen. + +# Names in __all__ with no definition: +# datafile +# io +# ipc +# protocol +# schema diff --git a/typeshed/3/avro/schema.pyi b/typeshed/3/avro/schema.pyi new file mode 100644 index 000000000..5276b29a3 --- /dev/null +++ b/typeshed/3/avro/schema.pyi @@ -0,0 +1,180 @@ +# Stubs for avro.schema (Python 3.5) +# +# NOTE: This dynamically typed stub was automatically generated by stubgen. + +from typing import Any, Optional + +logger = ... # type: Any +DEBUG_VERBOSE = ... # type: int +NULL = ... # type: str +BOOLEAN = ... # type: str +STRING = ... # type: str +BYTES = ... # type: str +INT = ... # type: str +LONG = ... # type: str +FLOAT = ... # type: str +DOUBLE = ... # type: str +FIXED = ... # type: str +ENUM = ... # type: str +RECORD = ... # type: str +ERROR = ... # type: str +ARRAY = ... # type: str +MAP = ... # type: str +UNION = ... # type: str +REQUEST = ... # type: str +ERROR_UNION = ... # type: str +PRIMITIVE_TYPES = ... # type: Any +NAMED_TYPES = ... # type: Any +VALID_TYPES = ... # type: Any +SCHEMA_RESERVED_PROPS = ... # type: Any +FIELD_RESERVED_PROPS = ... # type: Any +VALID_FIELD_SORT_ORDERS = ... # type: Any + +class Error(Exception): ... +class AvroException(Error): ... +class SchemaParseException(AvroException): ... + +class ImmutableDict(dict): + def __init__(self, items: Optional[Any] = ..., **kwargs) -> None: ... + def __setitem__(self, key, value): ... + def __delitem__(self, key): ... + def clear(self): ... + def update(self, **kwargs): ... + def pop(self, key, default: Optional[Any] = ...): ... + def popitem(self): ... + +class Schema: + def __init__(self, type, other_props: Optional[Any] = ...) -> None: ... + @property + def name(self): ... + @property + def fullname(self): ... + @property + def namespace(self): ... + @property + def type(self): ... + @property + def doc(self): ... + @property + def props(self): ... + @property + def other_props(self): ... + def to_json(self, names): ... + +class Name: + def __init__(self, name, namespace: Optional[Any] = ...) -> None: ... + def __eq__(self, other): ... + @property + def simple_name(self): ... + @property + def namespace(self): ... + @property + def fullname(self): ... + +class Names: + def __init__(self, default_namespace: Optional[Any] = ..., names: Optional[Any] = ...) -> None: ... + @property + def names(self): ... + @property + def default_namespace(self): ... + def NewWithDefaultNamespace(self, namespace): ... + def GetName(self, name, namespace: Optional[Any] = ...): ... + def has_name(self, name, namespace: Optional[Any] = ...): ... + def get_name(self, name, namespace: Optional[Any] = ...): ... + def GetSchema(self, name, namespace: Optional[Any] = ...): ... + def prune_namespace(self, properties): ... + def Register(self, schema): ... + +class NamedSchema(Schema): + def __init__(self, type, name, namespace: Optional[Any] = ..., names: Optional[Any] = ..., other_props: Optional[Any] = ...) -> None: ... + @property + def avro_name(self): ... + @property + def name(self): ... + @property + def namespace(self): ... + @property + def fullname(self): ... + def name_ref(self, names): ... + +class Field: + def __init__(self, type, name, index, has_default, default: Any = ..., order: Optional[Any] = ..., names: Optional[Any] = ..., doc: Optional[Any] = ..., other_props: Optional[Any] = ...) -> None: ... + @property + def type(self): ... + @property + def name(self): ... + @property + def index(self): ... + @property + def default(self): ... + @property + def has_default(self): ... + @property + def order(self): ... + @property + def doc(self): ... + @property + def props(self): ... + @property + def other_props(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class PrimitiveSchema(Schema): + def __init__(self, type, other_props: Optional[Any] = ...) -> None: ... + @property + def name(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class FixedSchema(NamedSchema): + def __init__(self, name, namespace, size, names: Optional[Any] = ..., other_props: Optional[Any] = ...) -> None: ... + @property + def size(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class EnumSchema(NamedSchema): + def __init__(self, name, namespace, symbols, names: Optional[Any] = ..., doc: Optional[Any] = ..., other_props: Optional[Any] = ...) -> None: ... + @property + def symbols(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class ArraySchema(Schema): + def __init__(self, items, other_props: Optional[Any] = ...) -> None: ... + @property + def items(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class MapSchema(Schema): + def __init__(self, values, other_props: Optional[Any] = ...) -> None: ... + @property + def values(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class UnionSchema(Schema): + def __init__(self, schemas) -> None: ... + @property + def schemas(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +class ErrorUnionSchema(UnionSchema): + def __init__(self, schemas) -> None: ... + def to_json(self, names: Optional[Any] = ...): ... + +class RecordSchema(NamedSchema): + def __init__(self, name, namespace, fields: Optional[Any] = ..., make_fields: Optional[Any] = ..., names: Optional[Any] = ..., record_type: Any = ..., doc: Optional[Any] = ..., other_props: Optional[Any] = ...) -> None: ... + @property + def fields(self): ... + @property + def field_map(self): ... + def to_json(self, names: Optional[Any] = ...): ... + def __eq__(self, that): ... + +def FilterKeysOut(items, keys): ... +def SchemaFromJSONData(json_data, names: Optional[Any] = ...): ... +def Parse(json_string): ...