From 9993a9696531ecf787d9610caaf2eef3607def03 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Jan 2020 06:44:34 +0100 Subject: [PATCH 01/12] add typing --- py/__init__.pyi | 5 +++++ py/path/__init__.pyi | 1 + 2 files changed, 6 insertions(+) create mode 100644 py/__init__.pyi create mode 100644 py/path/__init__.pyi diff --git a/py/__init__.pyi b/py/__init__.pyi new file mode 100644 index 00000000..caa0eef1 --- /dev/null +++ b/py/__init__.pyi @@ -0,0 +1,5 @@ +from py._error import ErrorMaker + +from . import path + +error: ErrorMaker diff --git a/py/path/__init__.pyi b/py/path/__init__.pyi new file mode 100644 index 00000000..4c16fba8 --- /dev/null +++ b/py/path/__init__.pyi @@ -0,0 +1 @@ +from .local import LocalPath as local From 39adf2dcfae51cafef24fdc9c9b4f9d670d90230 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Jan 2020 06:47:35 +0100 Subject: [PATCH 02/12] generated local.pyi --- py/path/local.pyi | 89 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 py/path/local.pyi diff --git a/py/path/local.pyi b/py/path/local.pyi new file mode 100644 index 00000000..9b5c5bb5 --- /dev/null +++ b/py/path/local.pyi @@ -0,0 +1,89 @@ +from py._path import common as common +from typing import Any, Optional + +def map_as_list(func: Any, iter: Any) -> Any: ... + +ALLOW_IMPORTLIB_MODE: Any + +class Stat: + def __getattr__(self, name: Any) -> Any: ... + path: Any = ... + def __init__(self, path: Any, osstatresult: Any) -> None: ... + @property + def owner(self) -> None: ... + @property + def group(self) -> None: ... + def isdir(self) -> None: ... + def isfile(self) -> None: ... + def islink(self) -> None: ... + +class PosixPath(common.PathBase): + def chown(self, user: Any, group: Any, rec: int=...) -> Any: ... + def readlink(self) -> None: ... + def mklinkto(self, oldname: Any) -> None: ... + def mksymlinkto(self, value: Any, absolute: int=...) -> None: ... + +def getuserid(user: Any) -> Any: ... +def getgroupid(group: Any) -> Any: ... + +FSBase: Any + +class LocalPath(FSBase): + class ImportMismatchError(ImportError): ... + sep: Any = ... + class Checkers(common.Checkers): + def dir(self) -> None: ... + def file(self) -> None: ... + def exists(self) -> None: ... + def link(self) -> None: ... + strpath: Any = ... + def __init__(self, path: Optional[Any]=..., expanduser: bool=...) -> None: ... + def __hash__(self) -> Any: ... + def __eq__(self, other: Any) -> Any: ... + def __ne__(self, other: Any) -> Any: ... + def __lt__(self, other: Any) -> Any: ... + def __gt__(self, other: Any) -> Any: ... + def samefile(self, other: Any) -> Any: ... + def remove(self, rec: int=..., ignore_errors: bool=...) -> None: ... + def computehash(self, hashtype: str=..., chunksize: int=...) -> Any: ... + def new(self, **kw: Any) -> Any: ... + def dirpath(self, *args: Any, **kwargs: Any) -> Any: ... + def join(self, *args: Any, **kwargs: Any) -> Any: ... + def open(self, mode: str=..., ensure: bool=..., encoding: Optional[Any]=...) -> Any: ... + def islink(self) -> None: ... + def check(self, **kw: Any) -> Any: ... + def listdir(self, fil: Optional[Any]=..., sort: Optional[Any]=...) -> Any: ... + def size(self) -> None: ... + def mtime(self) -> None: ... + def copy(self, target: Any, mode: bool=..., stat: bool=...) -> Any: ... + def rename(self, target: Any) -> Any: ... + def dump(self, obj: Any, bin: int=...) -> None: ... + def mkdir(self, *args: Any) -> Any: ... + def write_binary(self, data: Any, ensure: bool=...) -> None: ... + def write_text(self, data: Any, encoding: Any, ensure: bool=...) -> None: ... + def write(self, data: Any, mode: str=..., ensure: bool=...) -> None: ... + def ensure(self, *args: Any, **kwargs: Any) -> Any: ... + def stat(self, raising: bool=...) -> Any: ... + def lstat(self) -> None: ... + def setmtime(self, mtime: Optional[Any]=...) -> Any: ... + def chdir(self) -> None: ... + def as_cwd(self) -> None: ... + def realpath(self) -> None: ... + def atime(self) -> None: ... + def chmod(self, mode: Any, rec: int=...) -> None: ... + def pypkgpath(self) -> None: ... + def pyimport(self, modname: Optional[Any]=..., ensuresyspath: bool=...) -> Any: ... + def sysexec(self, *argv: Any, **popen_opts: Any) -> Any: ... + def sysfind(cls: Any, name: Any, checker: Optional[Any]=..., paths: Optional[Any]=...) -> Any: ... + sysfind: Any = ... + @classmethod + def get_temproot(cls) -> None: ... + @classmethod + def mkdtemp(cls: Any, rootdir: Optional[Any]=...) -> Any: ... + def make_numbered_dir(cls: Any, prefix: str=..., rootdir: Optional[Any]=..., keep: int=..., lock_timeout: int=...) -> Any: ... + make_numbered_dir: Any = ... + +def copymode(src: Any, dest: Any) -> None: ... +def copystat(src: Any, dest: Any) -> None: ... +def copychunked(src: Any, dest: Any) -> None: ... +def isimportable(name: Any) -> Any: ... From 72be60884246f0d3ad589221bc7bf7158fa76ccc Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Jan 2020 06:48:47 +0100 Subject: [PATCH 03/12] generated common.pyi --- py/path/common.pyi | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 py/path/common.pyi diff --git a/py/path/common.pyi b/py/path/common.pyi new file mode 100644 index 00000000..5489e94e --- /dev/null +++ b/py/path/common.pyi @@ -0,0 +1,70 @@ +from typing import Any, Optional + +iswin32: Any +import_errors: Any + +class Checkers: + path: Any = ... + def __init__(self, path: Any) -> None: ... + def dir(self) -> None: ... + def file(self) -> None: ... + def dotfile(self): ... + def ext(self, arg: Any): ... + def exists(self) -> None: ... + def basename(self, arg: Any): ... + def basestarts(self, arg: Any): ... + def relto(self, arg: Any): ... + def fnmatch(self, arg: Any): ... + def endswith(self, arg: Any): ... + +class NeverRaised(Exception): ... + +class PathBase: + Checkers: Any = ... + def __div__(self, other: Any): ... + __truediv__: Any = ... + def basename(self): ... + basename: Any = ... + def dirname(self): ... + dirname: Any = ... + def purebasename(self): ... + purebasename: Any = ... + def ext(self): ... + ext: Any = ... + def dirpath(self, *args: Any, **kwargs: Any): ... + def read_binary(self): ... + def read_text(self, encoding: Any): ... + def read(self, mode: str = ...): ... + def readlines(self, cr: int = ...): ... + def load(self): ... + def move(self, target: Any) -> None: ... + def check(self, **kw: Any): ... + def fnmatch(self, pattern: Any): ... + def relto(self, relpath: Any): ... + def ensure_dir(self, *args: Any): ... + def bestrelpath(self, dest: Any): ... + def exists(self): ... + def isdir(self): ... + def isfile(self): ... + def parts(self, reverse: bool = ...): ... + def common(self, other: Any): ... + def __add__(self, other: Any): ... + def __cmp__(self, other: Any): ... + def __lt__(self, other: Any) -> Any: ... + def visit(self, fil: Optional[Any] = ..., rec: Optional[Any] = ..., ignore: Any = ..., bf: bool = ..., sort: bool = ...) -> None: ... + def samefile(self, other: Any): ... + def __fspath__(self): ... + +class Visitor: + rec: Any = ... + fil: Any = ... + ignore: Any = ... + breadthfirst: Any = ... + optsort: Any = ... + def __init__(self, fil: Any, rec: Any, ignore: Any, bf: Any, sort: Any) -> None: ... + def gen(self, path: Any) -> None: ... + +class FNMatcher: + pattern: Any = ... + def __init__(self, pattern: Any) -> None: ... + def __call__(self, path: Any): ... From 5c334a93766e2caeb7015f0b76e63e2642c74fad Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Sun, 12 Jan 2020 06:53:01 +0100 Subject: [PATCH 04/12] PathBase.strpath --- py/path/common.pyi | 2 ++ py/path/local.pyi | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/py/path/common.pyi b/py/path/common.pyi index 5489e94e..b70d15a4 100644 --- a/py/path/common.pyi +++ b/py/path/common.pyi @@ -20,6 +20,8 @@ class Checkers: class NeverRaised(Exception): ... class PathBase: + strpath: str + Checkers: Any = ... def __div__(self, other: Any): ... __truediv__: Any = ... diff --git a/py/path/local.pyi b/py/path/local.pyi index 9b5c5bb5..632325d4 100644 --- a/py/path/local.pyi +++ b/py/path/local.pyi @@ -1,6 +1,9 @@ -from py._path import common as common +import sys from typing import Any, Optional +from . import common + + def map_as_list(func: Any, iter: Any) -> Any: ... ALLOW_IMPORTLIB_MODE: Any @@ -26,7 +29,11 @@ class PosixPath(common.PathBase): def getuserid(user: Any) -> Any: ... def getgroupid(group: Any) -> Any: ... -FSBase: Any +# FSBase = not iswin32 and PosixPath or common.PathBase +if sys.platform != 'win32': + FSBase = PosixPath +else: + FSBase = common.PathBase class LocalPath(FSBase): class ImportMismatchError(ImportError): ... @@ -36,7 +43,6 @@ class LocalPath(FSBase): def file(self) -> None: ... def exists(self) -> None: ... def link(self) -> None: ... - strpath: Any = ... def __init__(self, path: Optional[Any]=..., expanduser: bool=...) -> None: ... def __hash__(self) -> Any: ... def __eq__(self, other: Any) -> Any: ... From 10e978d925e1126cb69a5d48e5b49ef6480e91b1 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Mon, 13 Jan 2020 03:16:30 +0100 Subject: [PATCH 05/12] py.__version__ --- py/__init__.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/py/__init__.pyi b/py/__init__.pyi index caa0eef1..9b31868e 100644 --- a/py/__init__.pyi +++ b/py/__init__.pyi @@ -3,3 +3,4 @@ from py._error import ErrorMaker from . import path error: ErrorMaker +__version__: str From a80d4ff60fdf5db7f879dbd971b67956c154a453 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 15 Jan 2020 12:01:59 +0100 Subject: [PATCH 06/12] py/py.typed --- py/py.typed | 1 + 1 file changed, 1 insertion(+) create mode 100644 py/py.typed diff --git a/py/py.typed b/py/py.typed new file mode 100644 index 00000000..b648ac92 --- /dev/null +++ b/py/py.typed @@ -0,0 +1 @@ +partial From 404bd24b45c0eb0d73daa8abe1248e2f760d1962 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 15 Jan 2020 12:02:49 +0100 Subject: [PATCH 07/12] package_data --- setup.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/setup.py b/setup.py index a8a80e35..f10953d9 100644 --- a/setup.py +++ b/setup.py @@ -36,6 +36,9 @@ def main(): ], packages=find_packages(exclude=['tasks', 'testing']), zip_safe=False, + package_data={ + "": ["py.typed"], + }, ) if __name__ == '__main__': From fc165f5ceffe0021c9bf7320d6bff1755fec6ec3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Thu, 16 Jan 2020 14:11:37 +0100 Subject: [PATCH 08/12] generated py/_io/terminalwriter.pyi --- py/_io/terminalwriter.pyi | 72 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 py/_io/terminalwriter.pyi diff --git a/py/_io/terminalwriter.pyi b/py/_io/terminalwriter.pyi new file mode 100644 index 00000000..23dc0e2e --- /dev/null +++ b/py/_io/terminalwriter.pyi @@ -0,0 +1,72 @@ +import ctypes +from py.builtin import bytes as bytes, text as text +from typing import Any, Optional + +py3k: Any +py33: Any +win32_and_ctypes: bool +colorama: Any + +def get_terminal_width(): ... + +terminal_width: Any +char_width: Any + +def get_line_width(text: Any): ... +def ansi_print(text: Any, esc: Any, file: Optional[Any] = ..., newline: bool = ..., flush: bool = ...) -> None: ... +def should_do_markup(file: Any): ... + +class TerminalWriter: + stringio: Any = ... + encoding: Any = ... + hasmarkup: Any = ... + def __init__(self, file: Optional[Any] = ..., stringio: bool = ..., encoding: Optional[Any] = ...) -> None: ... + @property + def fullwidth(self): ... + @fullwidth.setter + def fullwidth(self, value: Any) -> None: ... + @property + def chars_on_current_line(self): ... + @property + def width_of_current_line(self): ... + def markup(self, text: Any, **kw: Any): ... + def sep(self, sepchar: Any, title: Optional[Any] = ..., fullwidth: Optional[Any] = ..., **kw: Any) -> None: ... + def write(self, msg: Any, **kw: Any) -> None: ... + def line(self, s: str = ..., **kw: Any) -> None: ... + def reline(self, line: Any, **kw: Any) -> None: ... + +class Win32ConsoleWriter(TerminalWriter): + def write(self, msg: Any, **kw: Any) -> None: ... + +class WriteFile: + encoding: Any = ... + def __init__(self, writemethod: Any, encoding: Optional[Any] = ...) -> None: ... + def write(self, data: Any) -> None: ... + def flush(self) -> None: ... +TerminalWriter = Win32ConsoleWriter +STD_OUTPUT_HANDLE: int +STD_ERROR_HANDLE: int +FOREGROUND_BLACK: int +FOREGROUND_BLUE: int +FOREGROUND_GREEN: int +FOREGROUND_RED: int +FOREGROUND_WHITE: int +FOREGROUND_INTENSITY: int +BACKGROUND_BLACK: int +BACKGROUND_BLUE: int +BACKGROUND_GREEN: int +BACKGROUND_RED: int +BACKGROUND_WHITE: int +BACKGROUND_INTENSITY: int +SHORT = ctypes.c_short + +class COORD(ctypes.Structure): ... +class SMALL_RECT(ctypes.Structure): ... +class CONSOLE_SCREEN_BUFFER_INFO(ctypes.Structure): ... + +def GetStdHandle(kind: Any): ... + +SetConsoleTextAttribute: Any + +def GetConsoleInfo(handle: Any): ... +def write_out(fil: Any, msg: Any) -> None: ... From 32ae0a3f0157654c445c82f04168695c882c5f82 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 17 Jan 2020 08:19:02 +0100 Subject: [PATCH 09/12] fix make_numbered_dir --- py/path/local.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/py/path/local.pyi b/py/path/local.pyi index 632325d4..4cad45e4 100644 --- a/py/path/local.pyi +++ b/py/path/local.pyi @@ -86,8 +86,7 @@ class LocalPath(FSBase): def get_temproot(cls) -> None: ... @classmethod def mkdtemp(cls: Any, rootdir: Optional[Any]=...) -> Any: ... - def make_numbered_dir(cls: Any, prefix: str=..., rootdir: Optional[Any]=..., keep: int=..., lock_timeout: int=...) -> Any: ... - make_numbered_dir: Any = ... + def make_numbered_dir(prefix: str=..., rootdir: Optional[Any]=..., keep: Optional[int]=..., lock_timeout: int=...) -> Any: ... def copymode(src: Any, dest: Any) -> None: ... def copystat(src: Any, dest: Any) -> None: ... From 82bb08a5ec3da95490931ca59485a74ddda2c339 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 17 Jan 2020 10:53:12 +0100 Subject: [PATCH 10/12] py/__init__.pyi: iniconfig, TerminalWriter --- py/__init__.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/__init__.pyi b/py/__init__.pyi index 9b31868e..992dee83 100644 --- a/py/__init__.pyi +++ b/py/__init__.pyi @@ -1,6 +1,8 @@ from py._error import ErrorMaker from . import path +from ._vendored_packages import iniconfig +from .io import TerminalWriter error: ErrorMaker __version__: str From 66fc1bf4d7f5cebb959f98cbd282f33cbe2dda61 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 17 Jan 2020 12:12:13 +0100 Subject: [PATCH 11/12] TEMP: no CI --- .travis.yml | 69 ---------------------------------------------------- appveyor.yml | 32 ------------------------ 2 files changed, 101 deletions(-) delete mode 100644 .travis.yml delete mode 100644 appveyor.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 445835b4..00000000 --- a/.travis.yml +++ /dev/null @@ -1,69 +0,0 @@ -dist: xenial -language: python - -python: - - '2.7' - - '3.4' - - '3.5' - - '3.6' - - '3.7' - # - 'pypy2.7-6.0' - - 'pypy3.5-6.0' - -env: - global: - - COVERAGE_PROCESS_START=$PWD/tox.ini - matrix: - - DEPS="pytest~=2.9.0" - - DEPS="pytest~=3.0.0" - #- DEPS="pytest~=3.1.0" - -stages: - - name: test - if: tag IS NOT present - - name: deploy - if: repo = pytest-dev/py AND tag IS present - -matrix: - include: - - python: '2.7' - # using a different option due to pytest-addopts pytester issues - env: PYTEST_XADDOPTS="-n auto --runslowtests" DEPS="pytest~=3.0.0 pytest-xdist<1.25 pytest-forked<0.3" - - - stage: deploy - python: '3.6' - env: - install: pip install -U setuptools setuptools_scm - script: skip - deploy: - provider: pypi - user: nicoddemus - distributions: sdist bdist_wheel - skip_upload_docs: true - password: - secure: VNYW/sZoD+9DzKCe6vANNXXJR7jP7rwySafQ33N1jAnCrdylQjEN/p6tSfUe8jDi3wDpLPL9h8pwfxuUT7CRxglHov3Qe7zSeywixvHan5aFahQiQ8+gucYIM7wITHH3oQs7jN35pnhdnF+QlW2+eDCL6qOLU5XwuRhsDKXjQ/hUWR5hlX5EniD1gzyKEf6j1YCpST87tKpeLwVEYEmsucdkUZuXhxDtyaWQHWiPsLWwh/slQtUJEHeLF26r8UxFy0RiGne9jR+CzRfH5ktcA9/pArvp4VuwOii+1TDxVSYP7+I8Z+eUKN9JBg12QLaHwoIN/8J+MvHCkuf+OGSLM3sEyNRJGDev372xg3K7ylIkeeK4WXirKEp2ojgN8tniloDjnwdu/gPWBnrXuooA60tNoByHFa8KbMZAr2B2sQeMxD4VZGr1N8l0rX4gRTrwvdk3i3ulLKVSwkXaGn+GrfZTTboa7dEnpuma8tv1niNCSpStYIy7atS8129+5ijV3OC8DzOMh/rVbO9WsDb/RPG3yjFiDvEJPIPeE0l/m5u42QBqtdZSS2ia7UWTJBiEY09uFMTRmH5hhE/1aiYBbvAztf5CReUbeKdSQz3L8TTSZqewtFZmXTkX97/xQnrEpsnGezIM2DNuMEuQG3MxGkNCxwbQKpx/bkHdrD75yMk= - on: - tags: true - repo: pytest-dev/py - - exclude: - - python: '3.7' - env: DEPS="pytest~=2.9.0" - - allow_failures: - - python: 'pypy2.7-6.0' - - python: 'pypy3.5-6.0' - -install: - - pip install -U coverage coverage-enable-subprocess pip setuptools setuptools_scm - - pip install $DEPS - - pip install -U . --force-reinstall - -script: - - coverage run -m pytest --lsof $PYTEST_XADDOPTS - -after_success: - - coverage combine - - coverage report -m - - coverage xml - - bash <(curl -s https://codecov.io/bash) -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -X fix -f coverage.xml -e TRAVIS_PYTHON_VERSION diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 4fc8afec..00000000 --- a/appveyor.yml +++ /dev/null @@ -1,32 +0,0 @@ -environment: - matrix: - # note: please use "tox --listenvs" to populate the build matrix below - - TOXENV: "py27-pytest29" - - TOXENV: "py27-pytest30" - - TOXENV: "py27-pytest31" - - TOXENV: "py34-pytest29" - - TOXENV: "py34-pytest30" - - TOXENV: "py34-pytest31" - - TOXENV: "py35-pytest29" - - TOXENV: "py35-pytest30" - - TOXENV: "py35-pytest31" - - TOXENV: "py36-pytest29" - - TOXENV: "py36-pytest30" - - TOXENV: "py36-pytest31" - - TOXENV: "py37-pytest30" - - TOXENV: "py37-pytest31" - -install: - - echo Installed Pythons - - dir c:\Python* - - - C:\Python37\python -m pip install --upgrade --pre tox - -build: false # Not a C# project, build stuff at the test step instead. - -test_script: - - C:\Python37\python -m tox - -# We don't deploy anything on tags with AppVeyor, we use Travis instead, so we -# might as well save resources -skip_tags: true From 097f157a8c7452f649fdab5e52ece812d7a911b3 Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Fri, 17 Jan 2020 13:37:43 +0100 Subject: [PATCH 12/12] .flake8 --- .flake8 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..70d570bf --- /dev/null +++ b/.flake8 @@ -0,0 +1,3 @@ +[flake8] +per-file-ignores = + **/*.pyi:E252,E301,E302,E305,E501,E701,E704,F401,F811,F821