Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
113 lines
2.9 KiB
Nix
113 lines
2.9 KiB
Nix
{
|
|
lib,
|
|
fetchFromGitHub,
|
|
runCommand,
|
|
stdenv,
|
|
clang_20,
|
|
buildNpmPackage,
|
|
docify,
|
|
testers,
|
|
writeText,
|
|
jq,
|
|
basedpyright,
|
|
pkg-config,
|
|
libsecret,
|
|
nix-update-script,
|
|
versionCheckHook,
|
|
}:
|
|
|
|
buildNpmPackage rec {
|
|
pname = "basedpyright";
|
|
version = "1.31.6";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "detachhead";
|
|
repo = "basedpyright";
|
|
tag = "v${version}";
|
|
hash = "sha256-SqG51pxkJQ/YrknSOMy6KWn1pvdgJa5CLnFl5naAPMA=";
|
|
};
|
|
|
|
npmDepsHash = "sha256-dwtMl5dFpol+J+cM6EHiwO+F93Iyurwx9Kr317IGtVw=";
|
|
npmWorkspace = "packages/pyright";
|
|
|
|
preBuild = ''
|
|
# Build the docstubs
|
|
cp -r packages/pyright-internal/typeshed-fallback docstubs
|
|
docify docstubs/stdlib --builtins-only --in-place
|
|
'';
|
|
|
|
nativeBuildInputs = [
|
|
docify
|
|
pkg-config
|
|
]
|
|
++ lib.optional stdenv.isDarwin [ clang_20 ]; # clang_21 breaks keytar
|
|
|
|
buildInputs = [ libsecret ];
|
|
|
|
postInstall = ''
|
|
mv "$out/bin/pyright" "$out/bin/basedpyright"
|
|
mv "$out/bin/pyright-langserver" "$out/bin/basedpyright-langserver"
|
|
# Remove dangling symlinks created during installation (remove -delete to just see the files, or -print '%l\n' to see the target
|
|
find -L $out -type l -print -delete
|
|
'';
|
|
|
|
nativeInstallCheckInputs = [ versionCheckHook ];
|
|
versionCheckProgramArg = "--version";
|
|
doInstallCheck = true;
|
|
|
|
passthru = {
|
|
updateScript = nix-update-script { };
|
|
tests = {
|
|
# We are expecting 4 errors. Any other amount would indicate not working
|
|
# stub files, for instance.
|
|
simple = testers.testEqualContents {
|
|
assertion = "simple type checking";
|
|
expected = writeText "expected" ''
|
|
4
|
|
'';
|
|
actual =
|
|
runCommand "actual"
|
|
{
|
|
nativeBuildInputs = [
|
|
jq
|
|
basedpyright
|
|
];
|
|
base = writeText "test.py" ''
|
|
import sys
|
|
from time import tzset
|
|
|
|
def print_string(a_string: str):
|
|
a_string += 42
|
|
print(a_string)
|
|
|
|
if sys.platform == "win32":
|
|
print_string(69)
|
|
this_function_does_not_exist("nice!")
|
|
else:
|
|
result_of_tzset_is_None: str = tzset()
|
|
'';
|
|
configFile = writeText "pyproject.toml" ''
|
|
[tool.pyright]
|
|
typeCheckingMode = "strict"
|
|
'';
|
|
}
|
|
''
|
|
(basedpyright --outputjson $base || true) | jq -r .summary.errorCount > $out
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
|
|
meta = {
|
|
changelog = "https://github.com/detachhead/basedpyright/releases/tag/${src.tag}";
|
|
description = "Type checker for the Python language";
|
|
homepage = "https://github.com/detachhead/basedpyright";
|
|
license = lib.licenses.mit;
|
|
mainProgram = "basedpyright";
|
|
maintainers = with lib.maintainers; [
|
|
kiike
|
|
misilelab
|
|
];
|
|
};
|
|
}
|