1{ lib
2, buildPythonPackage
3, fetchFromGitHub
4, pythonOlder
5, hypothesis
6, dataclasses
7, hypothesmith
8, pytestCheckHook
9, pyyaml
10, typing-extensions
11, typing-inspect
12, black
13, isort
14}:
15
16buildPythonPackage rec {
17 pname = "libcst";
18 version = "0.3.18";
19
20 # Some files for tests missing from PyPi
21 # https://github.com/Instagram/LibCST/issues/331
22 src = fetchFromGitHub {
23 owner = "instagram";
24 repo = pname;
25 rev = "v${version}";
26 sha256 = "sha256-19yGaKBLpGASSPv/aSX0kx9lh2JxKExHJDKKtuBbuqI=";
27 };
28
29 disabled = pythonOlder "3.6";
30
31 propagatedBuildInputs = [ hypothesis typing-extensions typing-inspect pyyaml ]
32 ++ lib.optional (pythonOlder "3.7") dataclasses;
33
34 checkInputs = [ black hypothesmith isort pytestCheckHook ];
35
36 # can't run tests due to circular dependency on hypothesmith -> licst
37 doCheck = false;
38
39 preCheck = ''
40 python -m libcst.codegen.generate visitors
41 python -m libcst.codegen.generate return_types
42 '';
43
44 pythonImportsCheck = [ "libcst" ];
45
46 meta = with lib; {
47 description = "A Concrete Syntax Tree (CST) parser and serializer library for Python.";
48 homepage = "https://github.com/Instagram/libcst";
49 license = with licenses; [ mit asl20 psfl ];
50 maintainers = with maintainers; [ ruuda SuperSandro2000 ];
51 };
52}