SynBioDex / pySBOL3

Native python implementation of SBOL 3.0 specification
MIT License
37 stars 16 forks source link

Keyword initialization treats empty string as None #208

Closed jakebeal closed 3 years ago

jakebeal commented 3 years ago

Using keyword initialization on a Sequence object, I find that the empty string is treated as equivalent to None, when they are different. This causes an error if I then try to append onto an empty sequence.

Minimal reproducing example:

import sbol3

doc = sbol3.Document()
sbol3.set_namespace('https://example.org')

s1 = sbol3.Sequence("foo", elements='')
s2 = sbol3.Sequence("foo")
s2.elements = ''

assert s1.elements == s2.elements # error: s1 is None rather than ''
tcmitchell commented 3 years ago

Good catch. The test for whether an initial value was present was if initial_value:. Since '' converts to boolean False, the property constructor was ignoring the initial value of an empty string.