ty icon indicating copy to clipboard operation
ty copied to clipboard

How to configure per-module ignores?

Open AlecThomson opened this issue 2 months ago • 6 comments

Question

Hi there,

Thanks for the huge amount of effort on this, and congrats on the v0.2 release!

I'm wanting to configure ty to ignore issues for a specific module. For example, I have a mypy configuration like:

[[tool.mypy.overrides]]
module = "astropy.*"

In truth, I'd rather be able to ignore a specific error on a per-module basis. For example, here I'd like to ignore just unresolved-attribute errors from astropy.units. Is it possible to configure this, currently? Thanks!

Version

ty 0.0.2 (42835578d 2025-12-16)

AlecThomson avatar Dec 18 '25 02:12 AlecThomson

You can use tool.ty.overrides to change the severity (enable or disable rules) for a subset of files:

[[tool.ty.overrides]]
include = ["tests/**", "**/test_*.py"]

[tool.ty.overrides.rules]
possibly-unresolved-reference = "warn"

Unlike mypy, it isn't module-based, but it should allow you to accomplish the same.

Unless you want to disable attribute errors anywhere in the code base if accessed on an object with a type from any astrolpy.* module.

https://docs.astral.sh/ty/reference/configuration/#overrides

MichaReiser avatar Dec 18 '25 07:12 MichaReiser

Thanks @MichaReiser.

Unless you want to disable attribute errors anywhere in the code base if accessed on an object with a type from any astrolpy.* module.

That's indeed what I'd be after. I don't want to disable the error globally, rather just for external modules that cause issues.

AlecThomson avatar Dec 18 '25 12:12 AlecThomson

Great. I'll close this issue then. But let us know if you run into any problems.

MichaReiser avatar Dec 18 '25 12:12 MichaReiser

Oh sorry, just to check. Is it just the case that its not possible at the moment to do per-module ignores?

AlecThomson avatar Dec 18 '25 12:12 AlecThomson

Oh sorry, just to check. Is it just the case that its not possible at the moment to do per-module ignores?

Can you say more about what you mean by per-module ignores?

MichaReiser avatar Dec 18 '25 12:12 MichaReiser

Unless you want to disable attribute errors anywhere in the code base if accessed on an object with a type from any astrolpy.* module.

Is this really a feature mypy offers? I'm not clear, because the config in the OP doesn't seem to be complete? It shows that you're overriding something for a certain set of modules, but it's not clear what config options you are setting for those modules.

This almost sounds like a use case for #2082 ?

carljm avatar Dec 19 '25 00:12 carljm

Sorry for any confusion. Indeed, the mypy configuration above simply ignores all errors from the specified module. I was curious to know if it was possible to configure something similar in ty.

My follow up question, which perhaps confused matters, was that it would potentially be preferable to have more granularity on a per-issue + per module basis. As far as I know this isn't possible MyPy, however.

In that sense, I think my question is a duplicate of #1354

AlecThomson avatar Dec 19 '25 02:12 AlecThomson

I'll close this as I considere it covered by #2082 and #1354

MichaReiser avatar Dec 19 '25 07:12 MichaReiser