diff --git a/qgis_deployment_toolbelt/plugins/plugin.py b/qgis_deployment_toolbelt/plugins/plugin.py index 886d12f0..b88ef78e 100644 --- a/qgis_deployment_toolbelt/plugins/plugin.py +++ b/qgis_deployment_toolbelt/plugins/plugin.py @@ -11,6 +11,8 @@ # ########## Libraries ############# # ################################## +# special +from __future__ import annotations # Standard library import configparser @@ -20,7 +22,6 @@ from enum import Enum from os.path import expanduser, expandvars from pathlib import Path -from sys import version_info from urllib.parse import quote, urlsplit, urlunsplit # 3rd party @@ -30,12 +31,6 @@ from qgis_deployment_toolbelt.utils.check_path import check_path from qgis_deployment_toolbelt.utils.slugger import sluggy -# Imports depending on Python version -if version_info[1] < 11: - from typing_extensions import Self -else: - from typing import Self - # ############################################################################# # ########## Globals ############### # ################################## @@ -80,14 +75,14 @@ class QgisPlugin: version: str = "latest" @classmethod - def from_dict(cls, input_dict: dict) -> Self: + def from_dict(cls, input_dict: dict) -> QgisPlugin: """Create object from a dictionary. Args: input_dict (dict): input dictionary Returns: - Self: instanciated object + QgisPlugin: instanciated object """ # map attributes names for k, v in cls.ATTR_MAP.items(): @@ -129,14 +124,14 @@ def from_dict(cls, input_dict: dict) -> Self: ) @classmethod - def from_plugin_folder(cls, input_plugin_folder: Path) -> Self: + def from_plugin_folder(cls, input_plugin_folder: Path) -> QgisPlugin: """Create object from a QGIS plugin folder. Must contain a metadata.txt file. Args: input_plugin_folder (Path): path to the folder containgin a QGIS plugin Returns: - Self: instanciated object + QgisPlugin: instanciated object """ # check that input path is a folder check_path( @@ -167,14 +162,14 @@ def from_plugin_folder(cls, input_plugin_folder: Path) -> Self: return cls.from_dict(plugin_md_as_dict) @classmethod - def from_zip(cls, input_zip_path: Path) -> Self: + def from_zip(cls, input_zip_path: Path) -> QgisPlugin: """Create object from a ZIP file. Args: input_zip_path (Path): filepath of the input zip Returns: - Self: instanciated object + QgisPlugin: instanciated object """ with zipfile.ZipFile(file=input_zip_path) as zf: # find the metadata.txt file @@ -254,12 +249,12 @@ def installation_folder_name(self) -> str: else: return sluggy(self.name) - def is_older_than(self, version_to_compare: str | Self) -> bool: + def is_older_than(self, version_to_compare: str | QgisPlugin) -> bool: """Determine if the actual object version is older than the given version to \ compare. Args: - version_to_compare (Union[str, Self]): given version to compare with object version + version_to_compare (Union[str, QgisPlugin]): given version to compare with object version Returns: bool: True if the given version is newer (more recent) diff --git a/qgis_deployment_toolbelt/profiles/qdt_profile.py b/qgis_deployment_toolbelt/profiles/qdt_profile.py index 7a80edc9..503f91c7 100644 --- a/qgis_deployment_toolbelt/profiles/qdt_profile.py +++ b/qgis_deployment_toolbelt/profiles/qdt_profile.py @@ -11,19 +11,15 @@ # ########## Libraries ############# # ################################## +# special +from __future__ import annotations + # standard import json import logging from pathlib import Path -from sys import version_info from typing import Literal -# Imports depending on Python version -if version_info[1] < 11: - from typing_extensions import Self -else: - from typing import Self - # 3rd party from packaging.version import InvalidVersion, Version @@ -135,7 +131,7 @@ def __init__( @classmethod def from_json( cls, profile_json_path: Path, profile_folder: Path | None = None - ) -> "QdtProfile": + ) -> QdtProfile: """Load profile from a profile.json file. Args: @@ -301,12 +297,12 @@ def version(self) -> str: """ return self._version - def is_older_than(self, version_to_compare: str | Self) -> bool: + def is_older_than(self, version_to_compare: str | QdtProfile) -> bool: """Determine if the actual object version is older than the given version to compare. Args: - version_to_compare (Union[str, Self]): given version to compare with object + version_to_compare (Union[str, QdtProfile]): given version to compare with object version Returns: @@ -373,7 +369,7 @@ def status(self) -> Literal["downloaded", "installed", "unknown"]: return "unknown" @property - def installed_profile(self) -> "QdtProfile | None": + def installed_profile(self) -> QdtProfile | None: """Returns the installed profile object only if the corresponding profiles.json exists. diff --git a/requirements/base.txt b/requirements/base.txt index 644dcbc2..0d0bfc6a 100644 --- a/requirements/base.txt +++ b/requirements/base.txt @@ -6,4 +6,3 @@ packaging>=20,<24 pyyaml>=5.4,<7 pywin32==306 ; sys_platform == 'win32' requests>=2.31,<3 -typing-extensions>=4,<5 ; python_version < '3.11'