https://pantsbuild.org/ logo
b

bitter-ability-32190

12/02/2022, 8:53 PM
I'm hitting an issue with DictOption
fromfile
pointing to a YAML file where a newline at the end makes a difference. but the parsing code uses
.strip()
on the file contents. I think thats a bug?
c

curved-television-6568

12/02/2022, 8:56 PM
what difference does the newline do?
b

bitter-ability-32190

12/02/2022, 8:56 PM
It depends on the plugin, no?
In this case the copyright header being stamped is eating the first line 🙂
c

curved-television-6568

12/02/2022, 8:57 PM
oh… 👀
in my experience so is relying on whitespace in files, especially at the end, a source of headaches
b

bitter-ability-32190

12/02/2022, 8:58 PM
Shouldn't the underlying parsing libraries handle that though?
json.loads()
and
yaml_safe_load
?
c

curved-television-6568

12/02/2022, 8:58 PM
oh, they do. I mean that from a users perspective, so can the absence or presence of a final newline trip them up if that’s significant
b

bitter-ability-32190

12/02/2022, 8:59 PM
YAML is a god-awful spec, but... better than handcrafting JSON
c

curved-television-6568

12/02/2022, 8:59 PM
agree
b

bitter-ability-32190

12/02/2022, 8:59 PM
OK I'm gonna PR this
👀 1
c

curved-television-6568

12/02/2022, 9:09 PM
I see, so in this case, we tripped the user up, with no sensible out 😛
h

happy-kitchen-89482

12/02/2022, 11:14 PM
Yeah, that is a bug
We should not strip if the newline is significant!
I’ll bet I was the one that introduced that .strip() unnecessarily