Skip to content

Commit

Permalink
python3Packages.basedmypy: init at 2.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PerchunPak committed Dec 13, 2024
1 parent 773791c commit 63e9413
Show file tree
Hide file tree
Showing 3 changed files with 161 additions and 0 deletions.
133 changes: 133 additions & 0 deletions pkgs/development/python-modules/basedmypy/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
{
lib,
buildPythonPackage,
fetchFromGitHub,
nix-update-script,
pythonAtLeast,
pythonOlder,
stdenv,

# build-system
setuptools,
types-psutil,
types-setuptools,
wheel,

# propagates
basedtyping,
mypy-extensions,
tomli,
typing-extensions,

# optionals
lxml,
psutil,

# tests
attrs,
filelock,
pytest-xdist,
pytestCheckHook,
}:

buildPythonPackage rec {
pname = "basedmypy";
version = "2.8.1";
pyproject = true;

disabled = pythonOlder "3.8";

src = fetchFromGitHub {
owner = "KotlinIsland";
repo = "basedmypy";
tag = "v${version}";
hash = "sha256-scPIcUoay8cChiKNhaXcKjN5S5G7teGCakkaFMmAJlo=";
};

patches = [ ./unpin-types-setuptools.patch ];

build-system = [
basedtyping
mypy-extensions
setuptools
types-psutil
types-setuptools
typing-extensions
wheel
] ++ lib.optionals (pythonOlder "3.11") [ tomli ];

dependencies = [
basedtyping
mypy-extensions
typing-extensions
] ++ lib.optionals (pythonOlder "3.11") [ tomli ];

optional-dependencies = {
dmypy = [ psutil ];
reports = [ lxml ];
};

# Compile mypy with mypyc, which makes mypy about 4 times faster. The compiled
# version is also the default in the wheels on Pypi that include binaries.
# is64bit: unfortunately the build would exhaust all possible memory on i686-linux.
env.MYPY_USE_MYPYC = stdenv.buildPlatform.is64bit;

# when testing reduce optimisation level to reduce build time by 20%
env.MYPYC_OPT_LEVEL = 1;

pythonImportsCheck =
[
"mypy"
"mypy.api"
"mypy.fastparse"
"mypy.types"
"mypyc"
"mypyc.analysis"
]
++ lib.optionals (!stdenv.hostPlatform.isi686) [
# ImportError: cannot import name 'map_instance_to_supertype' from partially initialized module 'mypy.maptype' (most likely due to a circular import)
"mypy.report"
];

nativeCheckInputs = [
attrs
filelock
pytest-xdist
pytestCheckHook
setuptools
tomli
] ++ lib.flatten (lib.attrValues optional-dependencies);

disabledTests =
[ ]
++ lib.optionals (pythonAtLeast "3.12") [
# requires distutils
"test_c_unit_test"
];

disabledTestPaths =
[
# fails to find tyoing_extensions
"mypy/test/testcmdline.py"
"mypy/test/testdaemon.py"
# fails to find setuptools
"mypyc/test/test_commandline.py"
# fails to find hatchling
"mypy/test/testpep561.py"
]
++ lib.optionals stdenv.hostPlatform.isi686 [
# https://github.com/python/mypy/issues/15221
"mypyc/test/test_run.py"
];

passthru.updateScript = nix-update-script { };

meta = {
description = "Based Python static type checker with baseline, sane default settings and based typing features";
homepage = "https://kotlinisland.github.io/basedmypy/";
changelog = "https://github.com/KotlinIsland/basedmypy/blob/${src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
mainProgram = "mypy";
maintainers = with lib.maintainers; [ perchun ];
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
diff --git a/pyproject.toml b/pyproject.toml
index e395ede..c0d7d79 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -12,7 +12,7 @@ requires = [
"tomli>=1.1.0; python_version<'3.11'",
# the following is from build-requirements.txt
"types-psutil",
- "types-setuptools==68.2.0.0",
+ "types-setuptools>=68.2.0.0",
]
build-backend = "setuptools.build_meta"

diff --git a/test-requirements.txt b/test-requirements.txt
index f4fb4a2..9be9e83 100644
--- a/test-requirements.txt
+++ b/test-requirements.txt
@@ -51,7 +51,7 @@ tomli==2.0.1
# via -r test-requirements.in
types-psutil==5.9.5.17
# via -r build-requirements.txt
-types-setuptools==68.2.0.0
+types-setuptools>=68.2.0.0
# via -r build-requirements.txt
typing-extensions==4.12.2
# via -r mypy-requirements.txt
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1502,6 +1502,8 @@ self: super: with self; {

basedtyping = callPackage ../development/python-modules/basedtyping { };

basedmypy = callPackage ../development/python-modules/basedmypy { };

baseline = callPackage ../development/python-modules/baseline { };

baselines = callPackage ../development/python-modules/baselines { };
Expand Down

0 comments on commit 63e9413

Please sign in to comment.