https://pantsbuild.org/ logo
h

hundreds-breakfast-49010

08/14/2019, 6:38 PM
I assume somehow we're tagging some but not all python source files to get typechecked by that script
☝️ 1
g

gentle-wolf-58752

08/14/2019, 6:52 PM
h

hundreds-breakfast-49010

08/14/2019, 6:53 PM
ok, so we should probably be adding {type_checked} to new python source files we create as a matter of course, right?
actually ,how does this interact with the
python_library()
function in existing BUILD files?
g

gentle-wolf-58752

08/14/2019, 7:10 PM
To the first question, yes. I’m not sure there are any cases where we wouldn’t want to add type hints to new python.
Not sure I follow the second question though
w

witty-crayon-22786

08/14/2019, 7:13 PM
one case where you might not be able to is if you have code that mypy "fails on" anywhere in your dependencies
there are some patterns that mypy just bans rather than ignoring.
Eric had said that
datatype
is one of them, unfortunately
g

gentle-wolf-58752

08/14/2019, 7:18 PM
ah, that may explain the issues i was running into in https://github.com/pantsbuild/pants/pull/8170#discussion_r313556379
h

hundreds-breakfast-49010

08/14/2019, 7:21 PM
@gentle-wolf-58752 in the BUILD files for directories containing new python files I'm adding
they often just have the line
python_library()
so I'm not sure how I'd add the typechecking tag to those new files, or if the
python_library()
call is already doing that
maybe I can pass
tag
as a parameter to that call, but then that would presumably set up the tag for every python source file including ones that I'm not touching and don't necessarily want to start typechecking
w

witty-crayon-22786

08/14/2019, 7:23 PM
er
so,
python_library()
is just a target
it can take arguments, but in that case, none are being passed
if you wanted to pass tags, that would just look like
python_library(tags=['type_checked'])
all of the arguments are optional in that case for various reasons: see https://www.pantsbuild.org/build_files.html#target-definitions
name is optional if you want to have
name==directory
sources are optional if you want to glob the default sources for the target type
dependencies are optional if you don't any dependencies, etcv
h

hundreds-breakfast-49010

08/14/2019, 7:27 PM
how would I pass the
type_checked
flag to just one .py file?
w

witty-crayon-22786

08/14/2019, 7:37 PM
you'd need to split the target into (at least) two targets, each of which owned a portion of the files in the directory
111 would discourage that.
...because it's boilerplatey
h

hundreds-breakfast-49010

08/14/2019, 7:48 PM
111?
3 Views