I'm not well versed in Python as I have a Java background. I have this simple class:
## Class declaration
class SemVersion:
major: int
minor: int
patch: int
def __init__(self, major, minor, patch):
self.major = major
self.minor = minor
self.patch = patch
def incrementMinor(self):
print(self)
self.minor = self.minor + 1
return self
def toString(self):
return self.major + "." + self.minor + "." + self.patch
def toSnapshotString(self):
return self.toString() + "-SNAPSHOT"
The following statement throws an error:
newDevelopVersion = releaseSemVersion.incrementMinor()
Exception:
Traceback (most recent call last): File "C:\devenv\java\apps\vsb-letters-transfer-api\release_preprod.py", line 41, in newDevelopVersion = releaseSemVersion.incrementMinor() File "C:\devenv\java\apps\vsb-letters-transfer-api\release_helpers.py", line 17, in incrementMinor self.minor = self.minor + 1 TypeError: can only concatenate str (not "int") to str
I'd like to understand how Python can manage not to recognize it as an integer as I declared it as such and just increment the way I asked it.
I'm sure there is a reasonable explanation for it.
I don't see how I asked anywhere to add a string to an int or anything of that nature.
Many thanks.
SemVersion(e.g. what arguments?). Type hints are only that, they do not enforce typing.releaseSemVersioninstance?