Open
Description
This is a WIP issue to gather all the ideas of what can reasonable be checked when setting, appending, replacing and Environment() variable.
Started as dicussion on discord
bdbaddogToday at 10:02 AM
I had an idea which probably belongs in #loony-channel ... It should be possible to write a SConstruct Lint mode..
so if you do thinks like env['LIBS']='a' instead of env['LIBS']=['a'], it would warn you etc..
The things an experienced user has done wrong and fixed.
mwichmannToday at 10:05 AM
probably
bdbaddogToday at 10:05 AM
I'm going to file an issue for that so it doesn't get lost.. and we can add ideas to it to flesh out what could be done?
mwichmannToday at 10:07 AM
any kind of checker/linter would be great, been on my wishlist
loonycyborgToday at 10:19 AM
scons scripts are python. Maybe it could be plugin of existing python checker?
bdbaddogToday at 10:22 AM
@loonycyborg - nope.. This would have to hook in to the logic which implements env['XYZ'] = value
mwichmannToday at 10:27 AM
I don't know that that particular one is a problem... env is much like a UserDict, where there's a backing data element (_dict), and pylint doesn't have any trouble with userdicts
but there's other goodies
(or _data, or whatever it's called)
mwichmannToday at 10:39 AM
Yet Another Nitpicky Question: if a consvar is set to a tuple, should you be able to append to it?
env['FOO'] = ('one', 'two')
env.Append(FOO="three")
what should happen?
bdbaddogToday at 10:43 AM
UserError.. ?
mwichmannToday at 10:45 AM
the current error message is unenlightening and indicates another unexpected path through a rather complex algorithm... AttributeError: 'str' object has no attribute 'insert':
the algorithm here takes new and inserts old in front of it, thus...
bdbaddogToday at 10:46 AM
that's not very helpful error message for sure.
mwichmannToday at 10:46 AM
it does that when they types differ and other conditions are not met, but it guessed wrong here :slight_smile:
bdbaddogToday at 10:50 AM
gotcha
loonycyborgToday at 11:01 AM
would be cool if env variables had some inherent type. Like if variable type is known as list then Appending either list or single item always has well defined semantic
bdbaddogToday at 11:02 AM
Moving to #loony-channel
Followed by
bdbaddogToday at 11:02 AM
@loonycyborg - yes that would make sense for some variables..
All of which (I think) falls under the umbrella of "make it harder to do bad/silly/un-sconsian things"
or make it easier to figure out how to do the "best" thing?
loonycyborgToday at 11:03 AM
Just to make things less tricky
if Append(x = "x") and Append (x = ["x"]) always does the same thing then it becomes less error prone
actually this can be formulated not as strict typing but rather having a strict "kind"
where "kind" is either scalar or list or mapping.
probably it's a good idea to make some env variables to always have some particular "kind"
and scons adjusting all operations like Append to act according to it
so far I encountered many issues due to particular variable having unexpected kind
while issue of wrong type is uncommon since everything tends to be string, or something stringifiable