Is there a way to configure the mypy typecheck par...
# general
b
Is there a way to configure the mypy typecheck particular to modules/apps?
e
Asking because I don't know: how would you do this Pants aside?
b
previously we just ran
mypy
against each individual app
h
What do you mean? There is a new feature in 2.5 to skip MyPy on certain targets when you run
./pants typecheck ::
https://www.pantsbuild.org/v2.5/docs/python-typecheck-goal#incrementally-adopt-mypy-with-skip_mypytrue
b
I have a repository with several django apps, for each app I need to be able to specify a different piece of configuration for mypy django-stubs plugin
that plugin unfortunately won't run without that setting set, it points to the django settings module for that project, so it's specific to the type checker configuration for that app alone
h
Ah. No, unfortunately that is not supported as MyPy itself does not support multiple config files The best you can get is dynamically setting the config file by changing
--mypy-config
or
PANTS_MYPY_CONFIG
env var. Or we could help with a plugin that behaves how you want, like running in multiple partitions and hardcoding that
projectA
should use
projectA/mypy.ini
e
Ah. No, unfortunately that is not supported as MyPy itself does not support multiple config files
That seems to contradict Nathan's current workflow. He does this somehow today.
b
hmm, ok, i'm thinking maybe this means i need to reevaluate how these apps are structured. They ultimately simple test apps, meant for functional and unit testing. So far I'd been trying to keep a sibling test app per published reusable app to keep the concerns isolated but maybe i just need to yield on that ideal and make a single monolithic app that integrates everything
e
@big-fall-51153 are they structured ~like Eric says with projectA/mypy.ini ?
h
He does this somehow today.
True, how are you doing this today?
b
each app is its own poetry project, so each of them have their own
mypy.ini
e
If so this sounds like - in Pants speak - mypy.ini per source root.
So, @big-fall-51153 today you must have PWD=projectA/ when running mypy?
b
correct, we only run it at the project level
e
Aha - there you go.
I think Eric is right, we could definitely support this.
h
Okay, so then you could sort of get things working in Pants 2.5 out of the box: Pants 2.5 adds config autodiscovery, so it will automatically include
projectA/mypy.ini
and
projectB/mypy.ini
etc. No need to set
[mypy].config
anymore However, MyPy only chooses one config file w/ it's autodiscovery logic. So you could not invoke
./pants typecheck ::
properly You would need to do
$ ./pants typecheck projectA:: ; ./pants typecheck projectB::
and so on. That could work, but ideally w/ Pants,
./pants typecheck ::
Just Works, which I think is where the plugin would come in to partition for you based on project
b
I think I actually won't end up needing that - talking this through made me realized that the project layout decision to put a testapp in each project was really a decision forced by poetry not supporting monorepos very well. There's not really a big benefit to continuing that practice, especially if it makes the integrate with pants a bit non-standard
🙌 1