1{
2 lib,
3 buildPythonPackage,
4 fetchFromGitHub,
5 isPy27,
6 isPy38,
7 isPy39,
8 pythonAtLeast,
9 flake8,
10 six,
11 python,
12}:
13
14buildPythonPackage rec {
15 pname = "flake8-future-import";
16 version = "0.4.7";
17 format = "setuptools";
18
19 # PyPI tarball doesn't include the test suite
20 src = fetchFromGitHub {
21 owner = "xZise";
22 repo = "flake8-future-import";
23 rev = "refs/tags/${version}";
24 hash = "sha256-2EcCOx3+PCk9LYpQjHCFNpQVI2Pdi+lWL8R6bNadFe0=";
25 };
26
27 patches =
28 lib.optionals (pythonAtLeast "3.10") [ ./fix-annotations-version-11.patch ]
29 ++ lib.optionals (isPy38 || isPy39) [ ./fix-annotations-version-10.patch ]
30 ++ lib.optionals isPy27 [
31 # Upstream disables this test case naturally on python 3, but it also fails
32 # inside NixPkgs for python 2. Since it's going to be deleted, we just skip it
33 # on py2 as well.
34 ./skip-test.patch
35 ];
36
37 postPatch = ''
38 substituteInPlace "test_flake8_future_import.py" \
39 --replace "'flake8'" "'${lib.getExe flake8}'"
40 '';
41
42 propagatedBuildInputs = [ flake8 ];
43
44 nativeCheckInputs = [ six ];
45
46 checkPhase = ''
47 runHook preCheck
48
49 ${python.interpreter} -m test_flake8_future_import
50
51 runHook postCheck
52 '';
53
54 meta = with lib; {
55 description = "Flake8 extension to check for the imported __future__ modules to make it easier to have a consistent code base";
56 homepage = "https://github.com/xZise/flake8-future-import";
57 license = licenses.mit;
58 };
59}