From 00f38e1a832f8b2e39f63f34e7ded26058ed8dbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Tue, 29 Mar 2022 16:43:53 +0200 Subject: [PATCH] python39Packages.hypothesmith: remove linting programs --- .../python-modules/hypothesmith/default.nix | 31 ++++++- .../hypothesmith/remove-black.patch | 88 +++++++++++++++++++ 2 files changed, 116 insertions(+), 3 deletions(-) create mode 100644 pkgs/development/python-modules/hypothesmith/remove-black.patch diff --git a/pkgs/development/python-modules/hypothesmith/default.nix b/pkgs/development/python-modules/hypothesmith/default.nix index 33174deb6573..ae02a076bafb 100644 --- a/pkgs/development/python-modules/hypothesmith/default.nix +++ b/pkgs/development/python-modules/hypothesmith/default.nix @@ -1,4 +1,13 @@ -{ lib, buildPythonPackage, fetchPypi, hypothesis, lark, libcst, black, parso, pytestCheckHook, pytest-cov, pytest-xdist }: +{ lib +, buildPythonPackage +, fetchPypi +, hypothesis +, lark +, libcst +, parso +, pytestCheckHook +, pytest-xdist +}: buildPythonPackage rec { pname = "hypothesmith"; @@ -9,19 +18,35 @@ buildPythonPackage rec { sha256 = "0fb7b3fd03d76eddd4474b0561e1c2662457593a74cc300fd27e5409cd4d7922"; }; + patches = [ + ./remove-black.patch + ]; + postPatch = '' - substituteInPlace setup.py --replace "lark-parser" "lark" + substituteInPlace setup.py \ + --replace "lark-parser" "lark" + + substituteInPlace tox.ini \ + --replace "--cov=hypothesmith" "" \ + --replace "--cov-branch" "" \ + --replace "--cov-report=term-missing:skip-covered" "" \ + --replace "--cov-fail-under=100" "" ''; propagatedBuildInputs = [ hypothesis lark libcst ]; - checkInputs = [ black parso pytestCheckHook pytest-cov pytest-xdist ]; + checkInputs = [ parso pytestCheckHook pytest-xdist ]; pytestFlagsArray = [ "-v" "--numprocesses $NIX_BUILD_CORES" ]; + disabledTests = [ + # https://github.com/Zac-HD/hypothesmith/issues/21 + "test_source_code_from_libcst_node_type" + ]; + pythonImportsCheck = [ "hypothesmith" ]; meta = with lib; { diff --git a/pkgs/development/python-modules/hypothesmith/remove-black.patch b/pkgs/development/python-modules/hypothesmith/remove-black.patch new file mode 100644 index 000000000000..565f350b06b4 --- /dev/null +++ b/pkgs/development/python-modules/hypothesmith/remove-black.patch @@ -0,0 +1,88 @@ +diff --git a/tests/test_cst.py b/tests/test_cst.py +index c436183..bdba2d7 100644 +--- a/tests/test_cst.py ++++ b/tests/test_cst.py +@@ -3,7 +3,6 @@ import ast + from inspect import isabstract + from operator import attrgetter + +-import black + import libcst + import parso + import pytest +@@ -51,27 +50,6 @@ def test_ast_unparse_from_nodes(source_code): + assert ast.dump(first) == ast.dump(second) + + +-@pytest.mark.xfail +-@example("A\u2592", black.FileMode()) +-@given( +- source_code=hypothesmith.from_node(), +- mode=st.builds( +- black.FileMode, +- line_length=st.just(88) | st.integers(0, 200), +- string_normalization=st.booleans(), +- is_pyi=st.booleans(), +- ), +-) +-def test_black_autoformatter_from_nodes(source_code, mode): +- try: +- result = black.format_file_contents(source_code, fast=False, mode=mode) +- except black.NothingChanged: +- pass +- else: +- with pytest.raises(black.NothingChanged): +- black.format_file_contents(result, fast=False, mode=mode) +- +- + @given(source_code=hypothesmith.from_node()) + def test_from_node_always_compilable(source_code): + compile(source_code, "", "exec") +diff --git a/tests/test_syntactic.py b/tests/test_syntactic.py +index 7ea42e9..a77ac39 100644 +--- a/tests/test_syntactic.py ++++ b/tests/test_syntactic.py +@@ -3,8 +3,6 @@ import ast + import io + import tokenize + +-import black +-import blib2to3 + import parso + import pytest + from hypothesis import example, given, reject, strategies as st +@@ -58,34 +56,6 @@ def test_ast_unparse_from_grammar(source_code): + assert ast.dump(first) == ast.dump(second) + + +-@example("\\", black.FileMode()) +-@example("A#\r#", black.FileMode()) +-@given( +- source_code=hypothesmith.from_grammar(), +- mode=st.builds( +- black.FileMode, +- line_length=st.just(88) | st.integers(0, 200), +- string_normalization=st.booleans(), +- is_pyi=st.booleans(), +- ), +-) +-def test_black_autoformatter_from_grammar(source_code, mode): +- try: +- result = black.format_file_contents(source_code, fast=False, mode=mode) +- except black.NothingChanged: +- pass +- except blib2to3.pgen2.tokenize.TokenError: +- # Fails to tokenise e.g. "\\", though compile("\\", "", "exec") works. +- # See https://github.com/psf/black/issues/1012 +- reject() +- except black.InvalidInput: +- # e.g. "A#\r#", see https://github.com/psf/black/issues/970 +- reject() +- else: +- with pytest.raises(black.NothingChanged): +- black.format_file_contents(result, fast=False, mode=mode) +- +- + @given(source_code=hypothesmith.from_grammar("eval_input")) + def test_eval_input_generation(source_code): + compile(source_code, filename="", mode="eval")