https://pantsbuild.org/ logo
b

bitter-ability-32190

04/28/2023, 4:22 PM
Anyone know why Python string import inference rejects middle dirs that are capitalized? E.g.
a.B.c
1
Copy code
>>> x = re.compile(r"^([a-z_][a-z_\d]*\.){2,}[a-zA-Z_]\w*$", re.UNICODE)
>>> x.match("a.b.c")
<re.Match object; span=(0, 5), match='a.b.c'>
>>> x.match("a.B.c")
>>>
b

bitter-ability-32190

04/28/2023, 4:27 PM
Right, but why did we make that regex so? Is it on purpose?
I'm porting the behavior so I wanna make sure I'm not missing something obvious
f

fast-nail-55400

04/28/2023, 4:28 PM
that I do not know
b

bitter-ability-32190

04/28/2023, 4:28 PM
git blame
time
c

curved-television-6568

04/28/2023, 6:33 PM
if
import a.B.c
is a valid thing, then this seems like a bug to me
b

bitter-ability-32190

04/28/2023, 6:58 PM
Yeah I can't see why not. Bugs going to be fixed soon
👍 1
h

happy-kitchen-89482

04/28/2023, 9:11 PM
The whole thing is a heuristic, and that capitalization is very non-standard (although, of course, allowed), so it seemed like the odds of it being a false positive were higher than it being a false negative.
So it's not a "bug" per se, just an attempt to keep the heuristic contained.
Maybe the alternative is better, maybe not
b

bitter-ability-32190

04/28/2023, 9:22 PM
The new world will be very permissive, as if we're wrong we just silently ignore the string
Assets are much more false-positive likely, but still. Likelihood should be low since string == target