コード例 #1
0
ファイル: test_mypy.py プロジェクト: jjpal/hypothesis
def get_mypy_output(fname, *extra_args):
    return subprocess.run(
        [tool_path("mypy"), *extra_args, fname],
        encoding="utf-8",
        capture_output=True,
        text=True,
    ).stdout
コード例 #2
0
def get_mypy_output(fname, *extra_args):
    return subprocess.Popen(
        [tool_path("mypy"), *extra_args, fname],
        stdout=subprocess.PIPE,
        encoding="utf-8",
        universal_newlines=True,
        # We set the MYPYPATH explicitly, because PEP561 discovery wasn't
        # working in CI as of mypy==0.730 - hopefully a temporary workaround.
        env=dict(os.environ, MYPYPATH=PYTHON_SRC),
    ).stdout.read()
コード例 #3
0
def _get_pyright_output(file: Path) -> dict[str, Any]:
    proc = subprocess.run(
        [tool_path("pyright"), "--outputjson"],
        cwd=file.parent,
        encoding="utf-8",
        text=True,
        capture_output=True,
    )
    try:
        return json.loads(proc.stdout)
    except Exception:
        print(proc.stdout)
        raise
コード例 #4
0
def get_mypy_analysed_type(fname, val):
    out = subprocess.Popen(
        [tool_path('mypy'), fname],
        stdout=subprocess.PIPE, encoding='utf-8', universal_newlines=True,
        # We set the MYPYPATH explicitly, because PEP561 discovery wasn't
        # working in CI as of mypy==0.600 - hopefully a temporary workaround.
        env=dict(os.environ, MYPYPATH=PYTHON_SRC),
    ).stdout.read()
    assert len(out.splitlines()) == 1
    # See https://mypy.readthedocs.io/en/latest/common_issues.html#reveal-type
    # The shell output for `reveal_type([1, 2, 3])` looks like a literal:
    # file.py:2: error: Revealed type is 'builtins.list[builtins.int*]'
    typ = out.split('error: Revealed type is ')[1].strip().strip("'")
    qualname = 'hypothesis.searchstrategy.strategies.SearchStrategy'
    assert typ.startswith(qualname)
    return typ[len(qualname) + 1:-1].replace('builtins.', '').replace('*', '')
コード例 #5
0
def get_mypy_analysed_type(fname, val):
    out = subprocess.Popen(
        [tool_path("mypy"), fname],
        stdout=subprocess.PIPE,
        encoding="utf-8",
        universal_newlines=True,
        # We set the MYPYPATH explicitly, because PEP561 discovery wasn't
        # working in CI as of mypy==0.730 - hopefully a temporary workaround.
        env=dict(os.environ, MYPYPATH=PYTHON_SRC),
    ).stdout.read()
    assert len(out.splitlines()) == 1
    # See https://mypy.readthedocs.io/en/latest/common_issues.html#reveal-type
    # The shell output for `reveal_type([1, 2, 3])` looks like a literal:
    # file.py:2: error: Revealed type is 'builtins.list[builtins.int*]'
    return (out.split("Revealed type is ")[1].strip().strip("'").replace(
        "builtins.", "").replace("*", ""))
コード例 #6
0
def get_mypy_analysed_type(fname, val):
    out = subprocess.Popen(
        [tool_path("mypy"), fname],
        stdout=subprocess.PIPE,
        encoding="utf-8",
        universal_newlines=True,
        # We set the MYPYPATH explicitly, because PEP561 discovery wasn't
        # working in CI as of mypy==0.600 - hopefully a temporary workaround.
        env=dict(os.environ, MYPYPATH=PYTHON_SRC),
    ).stdout.read()
    assert len(out.splitlines()) == 1
    # See https://mypy.readthedocs.io/en/latest/common_issues.html#reveal-type
    # The shell output for `reveal_type([1, 2, 3])` looks like a literal:
    # file.py:2: error: Revealed type is 'builtins.list[builtins.int*]'
    return (
        out.split("error: Revealed type is ")[1]
        .strip()
        .strip("'")
        .replace("builtins.", "")
        .replace("*", "")
    )
コード例 #7
0
from __future__ import division, print_function, absolute_import

import os
import re
import sys
from textwrap import dedent
from subprocess import PIPE, run
from collections import defaultdict
from distutils.version import StrictVersion

import hypothesistooling as tools
from hypothesistooling.scripts import tool_path
from hypothesistooling.projects.hypothesispython import BASE_DIR

SPHINXBUILD = tool_path('sphinx-build')


def dedent_lines(lines, force_newline=None):
    """Remove common leading whitespace from a list of strings."""
    if not lines:
        return []
    joiner = '' if lines[0].endswith('\n') else '\n'
    lines = dedent(joiner.join(lines)).split('\n')
    if force_newline is False:
        return lines
    if force_newline is True:
        return [l + '\n' for l in lines]
    return [l + (bool(joiner) * '\n') for l in lines]

コード例 #8
0
# END HEADER

from __future__ import division, print_function, absolute_import

import os
import re
import sys
from textwrap import dedent
from subprocess import PIPE, run
from collections import defaultdict
from distutils.version import StrictVersion

import hypothesistooling as tools
from hypothesistooling.scripts import tool_path

SPHINXBUILD = tool_path('sphinx-build')


def dedent_lines(lines, force_newline=None):
    """Remove common leading whitespace from a list of strings."""
    if not lines:
        return []
    joiner = '' if lines[0].endswith('\n') else '\n'
    lines = dedent(joiner.join(lines)).split('\n')
    if force_newline is False:
        return lines
    if force_newline is True:
        return [l + '\n' for l in lines]
    return [l + (bool(joiner) * '\n') for l in lines]

コード例 #9
0
from __future__ import absolute_import, division, print_function

import os
import re
import sys
from collections import defaultdict
from distutils.version import StrictVersion
from subprocess import PIPE, run
from textwrap import dedent

import hypothesistooling as tools
from hypothesistooling.projects.hypothesispython import BASE_DIR
from hypothesistooling.scripts import tool_path

SPHINXBUILD = tool_path("sphinx-build")


def dedent_lines(lines, force_newline=None):
    """Remove common leading whitespace from a list of strings."""
    if not lines:
        return []
    joiner = "" if lines[0].endswith("\n") else "\n"
    lines = dedent(joiner.join(lines)).split("\n")
    if force_newline is False:
        return lines
    if force_newline is True:
        return [l + "\n" for l in lines]
    return [l + (bool(joiner) * "\n") for l in lines]