I assume somehow we're tagging some but not all py...
# general
h
I assume somehow we're tagging some but not all python source files to get typechecked by that script
☝️ 1
g
h
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
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
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
ah, that may explain the issues i was running into in https://github.com/pantsbuild/pants/pull/8170#discussion_r313556379
h
@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
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
how would I pass the
type_checked
flag to just one .py file?
w
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
111?