2021-03-09 03:18:52 +00:00
|
|
|
{ lib
|
2021-06-28 23:13:55 +00:00
|
|
|
, black
|
2021-03-09 03:18:52 +00:00
|
|
|
, buildPythonPackage
|
2021-06-28 23:13:55 +00:00
|
|
|
, dataclasses
|
2021-03-09 03:18:52 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, hypothesis
|
2021-06-28 23:13:55 +00:00
|
|
|
, isort
|
|
|
|
, pytest
|
|
|
|
, python
|
|
|
|
, pythonOlder
|
2021-03-09 03:18:52 +00:00
|
|
|
, pyyaml
|
|
|
|
, typing-extensions
|
|
|
|
, typing-inspect
|
|
|
|
}:
|
2020-10-11 12:50:04 +00:00
|
|
|
|
|
|
|
buildPythonPackage rec {
|
|
|
|
pname = "libcst";
|
2021-09-18 10:52:07 +00:00
|
|
|
version = "0.3.20";
|
2021-06-28 23:13:55 +00:00
|
|
|
disabled = pythonOlder "3.6";
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
# Some files for tests missing from PyPi
|
|
|
|
# https://github.com/Instagram/LibCST/issues/331
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "instagram";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-09-18 10:52:07 +00:00
|
|
|
sha256 = "063bl21gyyd25i2v0j6kz29cxxdfhng2nins4i2qblmac90f2nqy";
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
hypothesis
|
|
|
|
typing-extensions
|
|
|
|
typing-inspect
|
|
|
|
pyyaml
|
|
|
|
] ++ lib.optional (pythonOlder "3.7") [
|
|
|
|
dataclasses
|
|
|
|
];
|
2021-03-09 03:18:52 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
checkInputs = [
|
|
|
|
black
|
|
|
|
isort
|
|
|
|
pytest
|
|
|
|
];
|
2020-10-16 20:44:37 +00:00
|
|
|
|
|
|
|
preCheck = ''
|
2021-06-28 23:13:55 +00:00
|
|
|
${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}
|
2020-10-16 20:44:37 +00:00
|
|
|
'';
|
2020-10-11 12:50:04 +00:00
|
|
|
|
2021-06-28 23:13:55 +00:00
|
|
|
disabledTests = [
|
|
|
|
# No files are generated
|
|
|
|
"test_codemod_formatter_error_input"
|
|
|
|
];
|
|
|
|
|
2020-10-11 12:50:04 +00:00
|
|
|
pythonImportsCheck = [ "libcst" ];
|
|
|
|
|
2020-10-16 20:44:37 +00:00
|
|
|
meta = with lib; {
|
2021-06-28 23:13:55 +00:00
|
|
|
description = "Concrete Syntax Tree (CST) parser and serializer library for Python";
|
2020-10-16 20:44:37 +00:00
|
|
|
homepage = "https://github.com/Instagram/libcst";
|
|
|
|
license = with licenses; [ mit asl20 psfl ];
|
2021-03-09 03:18:52 +00:00
|
|
|
maintainers = with maintainers; [ ruuda SuperSandro2000 ];
|
2020-10-11 12:50:04 +00:00
|
|
|
};
|
|
|
|
}
|