This PR refactors version comparisons in the application by utilizing packaging.version.Version more broadly.
The attribute zabbixcli.api_version has been removed, and zabbixcli.zabbix_version is now an instance of packaging.version.Version containing the full version number instead of a single integer denoting the major version.
All existing comparisons of zabbixcli.zabbix_version with integers have been rewritten to use zabbixcli.zabbix_version.major.
Similarly, all zabbixcli.api_version comparisons now use zabbixcli.zabbix_version.major and compare them with integers instead of comparing with other version objects.
On version comparisons
Comparing Version.release with version tuples ignores pre-release information, which is important to support users running pre-release (alpha/beta/rc) versions of Zabbix. Given the following Zabbix version:
version = Version("6.2.0alpha1")
We can't compare directly with a Version object (alpha < final):
>>> version >= Version("6.2.0")
False
Using release we can compare against a tuple of integers, thus alpha >= final:
>>> version.release >= (6,2,0)
True
In tuple comparisons, we can omit micro/patch version:
>>> version.release >= (6,2)
True
Comparing exact major and minor version is best done by constructing a tuple or comparing with major and minor:
This PR refactors version comparisons in the application by utilizing
packaging.version.Version
more broadly.The attribute
zabbixcli.api_version
has been removed, andzabbixcli.zabbix_version
is now an instance ofpackaging.version.Version
containing the full version number instead of a single integer denoting the major version.All existing comparisons of
zabbixcli.zabbix_version
with integers have been rewritten to usezabbixcli.zabbix_version.major
.Similarly, all
zabbixcli.api_version
comparisons now usezabbixcli.zabbix_version.major
and compare them with integers instead of comparing with other version objects.On version comparisons
Comparing
Version.release
with version tuples ignores pre-release information, which is important to support users running pre-release (alpha/beta/rc) versions of Zabbix. Given the following Zabbix version:We can't compare directly with a Version object (alpha < final):
Using
release
we can compare against a tuple of integers, thus alpha >= final:In tuple comparisons, we can omit micro/patch version:
Comparing exact major and minor version is best done by constructing a tuple or comparing with
major
andminor
:This lays the foundation for implementing specific minor version comparisons, such as the one required by #159.