Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable VersionInfo #97

Merged
merged 1 commit into from May 31, 2018
Merged

Immutable VersionInfo #97

merged 1 commit into from May 31, 2018

Conversation

scls19fr
Copy link
Member

Closes #96

@scls19fr
Copy link
Member Author

I don't understand why CI is broken with pypy and Python 2.7.

Any idea?

@scls19fr
Copy link
Member Author

CI fixed for Python 2.7 and PyPi
PR is ready to be merged in the next coming days.

semver.py Outdated
def build(self):
return self._build

def __setattr__(self, name, value):
Copy link
Member

Choose a reason for hiding this comment

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

I think this function is unnecessary

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought also that setattr wasn't necessary...
but not with Python 2.7 and Pypy

Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want to have private attributes be mutable?

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right ...
This build shows that __setattr__ is not required.

Although what is required for Python 2.7 and Pypi is inheriting VersionInfo from object.

@@ -414,3 +414,42 @@ def test_parse_method_for_version_info():
s_version = "1.2.3-alpha.1.2+build.11.e0f985a"
v = VersionInfo.parse(s_version)
assert str(v) == s_version


def test_immutable():
Copy link
Member

Choose a reason for hiding this comment

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

Could you also add a test to check if it's possible to add new attribute? Something like this:

try:
    v.some_attribute = 1
except:
    ...

semver.py Outdated
def build(self):
return self._build

def __setattr__(self, name, value):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we want to have private attributes be mutable?

semver.py Outdated

def __setattr__(self, name, value):
if name not in self.__slots__:
raise AttributeError
Copy link
Contributor

Choose a reason for hiding this comment

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

Even if so, it's better to pass name to AttributeError to avoid any confusions.

@scls19fr
Copy link
Member Author

Thanks @ppkt and @kxepal
Can I merge now?

Copy link
Contributor

@kxepal kxepal left a comment

Choose a reason for hiding this comment

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

LGFM 👍

Copy link
Member

@ppkt ppkt left a comment

Choose a reason for hiding this comment

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

Of course, thanks :)

@scls19fr scls19fr merged commit 97d41b9 into python-semver:master May 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants