Skip to content

make vstring/version variables in LooseVersion read-only#4156

Merged
boegel merged 3 commits into
easybuilders:developfrom
Flamefire:loose_version_none
Jan 4, 2023
Merged

make vstring/version variables in LooseVersion read-only#4156
boegel merged 3 commits into
easybuilders:developfrom
Flamefire:loose_version_none

Conversation

@Flamefire

Copy link
Copy Markdown
Contributor

The exposed "public" members .version and .vstring must not be modified from outside as they belong together. Hence put them into properties.

I was also thinking about the case of LooseVersion(None) which can easily happen with LooseVersion(get_software_version('Bazel')). One approach was to compare that equal to None or LooseVersion(None) and "less" otherwise. But that might be surprising and hence better/safer is if LooseVersion(...).version is None

I hence added that to the test suite to show an example and kept my WIP commit in the history if we later decide otherwise.

@boegel This should go into the next release which adds this class.

@boegel boegel added this to the next release (4.7.0) milestone Jan 4, 2023
@boegel boegel added the change label Jan 4, 2023
@boegel boegel changed the title Make LooseVersion readonly make vstring/version variables in LooseVersion read-only Jan 4, 2023
boegel
boegel previously approved these changes Jan 4, 2023

@boegel boegel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@Flamefire

Flamefire commented Jan 4, 2023

Copy link
Copy Markdown
Contributor Author

There was a use case that caused now test failures: loose_cv.version = loose_cv.version[:depth] in log.deprecated to only consider some parts of the version. I fixed that by comparing the list directly. I guess that works with the caveat that mixed-types in the components are no longer working. But I doubt we'd use that.

I still think this is a good idea because if anyone was to print the loose_cv it would turn up with the original value, not the modified one (which is the reason for this change)

@easybuilders easybuilders deleted a comment from boegelbot Jan 4, 2023

@boegel boegel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@boegel boegel merged commit c8d7400 into easybuilders:develop Jan 4, 2023
@Flamefire Flamefire deleted the loose_version_none branch January 5, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants