Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

python312Packages.libcst: move tests to passthru.tests #338508

Merged
merged 4 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 10 additions & 23 deletions pkgs/development/python-modules/hypothesmith/default.nix
Original file line number Diff line number Diff line change
@@ -1,65 +1,52 @@
{
lib,
black,
buildPythonPackage,
fetchPypi,
hypothesis,
lark,
libcst,
parso,
pytestCheckHook,
pytest-cov-stub,
pytest-xdist,
pythonOlder,
setuptools,
}:

buildPythonPackage rec {
pname = "hypothesmith";
version = "0.3.3";
format = "setuptools";
pyproject = true;

disabled = pythonOlder "3.8";
disabled = pythonOlder "3.9";

src = fetchPypi {
inherit pname version;
hash = "sha256-lsFIAtbI6F2JdSZBdoeNtUso0u2SH9v+3C5rjOPIFxY=";
};

patches = [ ./remove-black.patch ];
build-system = [ setuptools ];

postPatch = ''
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 = [
dependencies = [
hypothesis
lark
libcst
];

nativeCheckInputs = [
black
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to rely on linting tools like black.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not used for linting hypothesmith's code. It's used to lint the code generated by it afaict.

parso
pytestCheckHook
pytest-cov-stub
pytest-xdist
];

pytestFlagsArray = [ "-v" ];

disabledTests = [
# https://github.com/Zac-HD/hypothesmith/issues/21
# super slow
"test_source_code_from_libcst_node_type"
];

disabledTestPaths = [
# missing blib2to3
"tests/test_syntactic.py"
];

pythonImportsCheck = [ "hypothesmith" ];

meta = with lib; {
Expand Down
87 changes: 0 additions & 87 deletions pkgs/development/python-modules/hypothesmith/remove-black.patch

This file was deleted.

54 changes: 29 additions & 25 deletions pkgs/development/python-modules/libcst/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
stdenv,
buildPythonPackage,
fetchFromGitHub,
callPackage,
cargo,
hypothesis,
hypothesmith,
libcst,
libiconv,
pytestCheckHook,
python,
Expand All @@ -16,14 +18,15 @@
setuptools-scm,
typing-extensions,
typing-inspect,
ufmt,
}:

buildPythonPackage rec {
pname = "libcst";
version = "1.4.0";
format = "pyproject";
pyproject = true;

disabled = pythonOlder "3.7";
disabled = pythonOlder "3.9";

src = fetchFromGitHub {
owner = "instagram";
Expand All @@ -41,60 +44,61 @@ buildPythonPackage rec {

cargoRoot = "native";

postPatch = ''
# avoid infinite recursion by not formatting the release files
substituteInPlace libcst/codegen/generate.py \
--replace '"ufmt"' '"true"'
'';

nativeBuildInputs = [
build-system = [
setuptools-rust
setuptools-scm
];

nativeBuildInputs = [
rustPlatform.cargoSetupHook
cargo
rustc
];

buildInputs = lib.optionals stdenv.isDarwin [ libiconv ];

propagatedBuildInputs = [
dependencies = [
typing-extensions
typing-inspect
pyyaml
];

nativeCheckInputs = [
hypothesis
hypothesmith
pytestCheckHook
ufmt
];

preCheck = ''
# otherwise import libcst.native fails
cp build/lib.*/libcst/native.* libcst/

${python.interpreter} -m libcst.codegen.generate visitors
${python.interpreter} -m libcst.codegen.generate return_types

# Can't run all tests due to circular dependency on hypothesmith -> libcst
rm -r {libcst/tests,libcst/codegen/tests,libcst/m*/tests}
# import from $out instead
rm libcst/__init__.py
'';

disabledTests = [
# No files are generated
"test_codemod_formatter_error_input"
# FIXME package pyre-test
"TypeInferenceProviderTest"
# we'd need to run `python -m libcst.codegen.generate all` but shouldn't modify $out
"test_codegen_clean_visitor_functions"
];

# circular dependency on hypothesmith and ufmt
doCheck = false;

passthru.tests = {
pytest = libcst.overridePythonAttrs { doCheck = true; };
};

pythonImportsCheck = [ "libcst" ];

meta = with lib; {
meta = {
description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
homepage = "https://github.com/Instagram/libcst";
changelog = "https://github.com/Instagram/LibCST/blob/v${version}/CHANGELOG.md";
license = with licenses; [
license = with lib.licenses; [
mit
asl20
psfl
];
maintainers = [ ];
maintainers = with lib.maintainers; [ dotlambda ];
};
}