Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on how to configure mypy #247

Open
Ma27 opened this issue Oct 12, 2024 · 0 comments
Open

Clarification on how to configure mypy #247

Ma27 opened this issue Oct 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@Ma27
Copy link

Ma27 commented Oct 12, 2024

Describe the bug

With the mypy check from this repo, no files get checked with mypy on a treefmt run.

To Reproduce

Steps to reproduce the behavior:

  1. Given foo/bar.py
  2. Given the following treefmt-nix configuration (in flake.nix):
{
  treefmt = {
    projectRootFile = "flake.nix";
    programs = {
      nixfmt.enable = true;
      ruff.enable = true;
      mypy = {
        enable = true;
        directories = {
          ".".modules = [ "foo" ];
        };
      };
    };
  };

}
  1. Now running treefmt doesn't give any mypy errors.

I think part of the problem is the following in the final treefmt config:

includes = ["./foo/**/*.py"]

This doesn't seem to give any matches in treefmt.

After that I replaced the ".".modules = ["foo"] with ".".files = [ "*.py" ]. With that I got the following error:

+ /nix/store/ryp4vp6rs3d1gk0mgj6x8bncavsp4wqa-python3.12-mypy-1.10.1/bin/mypy '' '*.py'
mypy: can't read file '*.py': No such file or directory

This is because *.py isn't a recursive glob, however it's the glob needed for treefmt to validate a change in any Python file in a repo with mypy.

Expected behavior

I don't know, not sure if this is even a bug.

What am I supposed to do to let mypy run against a given module (foo)?

System information

NixOS 24.05, treefmt 2.0.5 (via treefmt-nix 879b29a), git-hooks.nix at rev 85f7a7177c678de68224af3402ab8ee1bcee25c8.

Additional context

@Ma27 Ma27 added the bug Something isn't working label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant