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