mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
mypy: init module (#7656)
This commit is contained in:
parent
3dcae8af51
commit
bc01493178
3 changed files with 100 additions and 0 deletions
50
modules/programs/mypy.nix
Normal file
50
modules/programs/mypy.nix
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
|
||||
iniFormat = pkgs.formats.ini { };
|
||||
cfg = config.programs.mypy;
|
||||
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ ];
|
||||
|
||||
options.programs.mypy = {
|
||||
enable = lib.mkEnableOption "mypy";
|
||||
|
||||
package = lib.mkPackageOption pkgs "mypy" { nullable = true; };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = iniFormat.type;
|
||||
default = { };
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
mypy = {
|
||||
warn_return_any = true;
|
||||
warn_unused_configs = true;
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/mypy/config`.
|
||||
|
||||
See <https://mypy.readthedocs.io/en/stable/config_file.html>
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
|
||||
xdg.configFile."mypy/config" = lib.mkIf (cfg.settings != { }) {
|
||||
source = iniFormat.generate "mypy-config" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
||||
47
tests/modules/programs/mypy/basic-config.nix
Normal file
47
tests/modules/programs/mypy/basic-config.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.mypy = {
|
||||
enable = true;
|
||||
|
||||
package = pkgs.mypy;
|
||||
|
||||
settings = {
|
||||
mypy = {
|
||||
warn_return_any = true;
|
||||
warn_unused_configs = true;
|
||||
};
|
||||
|
||||
"mypy-mycode.foo.*" = {
|
||||
disallow_untyped_defs = true;
|
||||
};
|
||||
|
||||
"mypy-mycode.bar".warn_return_any = false;
|
||||
|
||||
"mypy-somelibrary".ignore_missing_imports = true;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script =
|
||||
let
|
||||
configFile = "home-files/.config/mypy/config";
|
||||
in
|
||||
''
|
||||
assertFileExists ${configFile}
|
||||
assertFileContent ${configFile} \
|
||||
${pkgs.writeText "settings-expected" ''
|
||||
[mypy]
|
||||
warn_return_any=true
|
||||
warn_unused_configs=true
|
||||
|
||||
[mypy-mycode.bar]
|
||||
warn_return_any=false
|
||||
|
||||
[mypy-mycode.foo.*]
|
||||
disallow_untyped_defs=true
|
||||
|
||||
[mypy-somelibrary]
|
||||
ignore_missing_imports=true
|
||||
''}
|
||||
'';
|
||||
}
|
||||
3
tests/modules/programs/mypy/default.nix
Normal file
3
tests/modules/programs/mypy/default.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
mypy-basic-config = ./basic-config.nix;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue