https://pantsbuild.org/ logo
#general
Title
# general
b

big-fall-51153

05/13/2021, 3:17 PM
Is there a way to configure the mypy typecheck particular to modules/apps?
e

enough-analyst-54434

05/13/2021, 3:17 PM
Asking because I don't know: how would you do this Pants aside?
b

big-fall-51153

05/13/2021, 3:18 PM
previously we just ran
mypy
against each individual app
h

hundreds-father-404

05/13/2021, 3:19 PM
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

big-fall-51153

05/13/2021, 3:21 PM
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

hundreds-father-404

05/13/2021, 3:27 PM
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

enough-analyst-54434

05/13/2021, 3:34 PM
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

big-fall-51153

05/13/2021, 3:34 PM
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

enough-analyst-54434

05/13/2021, 3:35 PM
@big-fall-51153 are they structured ~like Eric says with projectA/mypy.ini ?
h

hundreds-father-404

05/13/2021, 3:35 PM
He does this somehow today.
True, how are you doing this today?
b

big-fall-51153

05/13/2021, 3:35 PM
each app is its own poetry project, so each of them have their own
mypy.ini
e

enough-analyst-54434

05/13/2021, 3:35 PM
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

big-fall-51153

05/13/2021, 3:37 PM
correct, we only run it at the project level
e

enough-analyst-54434

05/13/2021, 3:37 PM
Aha - there you go.
I think Eric is right, we could definitely support this.
h

hundreds-father-404

05/13/2021, 3:38 PM
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

big-fall-51153

05/13/2021, 3:43 PM
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
5 Views