about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/python-modules/hacking/default.nix
blob: 5a01f5246f85b9de62ccfc1a845335b1b3f6aa5a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{ lib
, buildPythonPackage
, fetchPypi
, pbr
, flake8
, stestr
, ddt
, testscenarios
}:

buildPythonPackage rec {
  pname = "hacking";
  version = "6.0.1";
  format = "setuptools";

  src = fetchPypi {
    inherit pname version;
    hash = "sha256-YdeEb8G58m7CFnjpkHQmkJX5ZNe72M1kbrbIxML4jcE=";
  };

  postPatch = ''
    sed -i 's/flake8.*/flake8/' requirements.txt
    substituteInPlace hacking/checks/python23.py \
      --replace 'H236: class Foo(object):\n    __metaclass__ = \' 'Okay: class Foo(object):\n    __metaclass__ = \'
    substituteInPlace hacking/checks/except_checks.py \
      --replace 'H201: except:' 'Okay: except:'
  '';

  nativeBuildInputs = [ pbr ];

  propagatedBuildInputs = [
    flake8
  ];

  nativeCheckInputs = [
    ddt
    stestr
    testscenarios
  ];

  checkPhase = ''
    # tries to trigger flake8 and fails
    rm hacking/tests/test_doctest.py

    stestr run
  '';

  pythonImportsCheck = [ "hacking" ];

  meta = with lib; {
    description = "OpenStack Hacking Guideline Enforcement";
    homepage = "https://github.com/openstack/hacking";
    license = licenses.asl20;
    maintainers = teams.openstack.members;
  };
}