Skip to content

Commit 782b014

Browse files
committed
refactor: enforce non-quoted type annotations
Enable ruff rules UP037 and FA to forbid quoted type annotations. Plain type annotations are cleaner, more readable, and enable better IDE support and type checking compared to string literals. Signed-off-by: Gaëtan Lehmann <gaetan.lehmann@vates.tech>
1 parent 2deda4d commit 782b014

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def host_data(hostname_or_ip: str) -> dict[str, str]:
5252

5353
class Host:
5454
xe_prefix = "host"
55-
pool: "Pool"
55+
pool: Pool
5656

5757
# Data extraction is automatic, no conversion from str is done.
5858
BlockDeviceInfo = TypedDict('BlockDeviceInfo', {"name": str,

lib/vm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def create_cd_vbd(self, device: str, userdevice: str) -> VBD:
656656
logging.info("New VBD %s", vbd_uuid)
657657
return vbd
658658

659-
def clone(self, *, name: str | None = None) -> "VM":
659+
def clone(self, *, name: str | None = None) -> VM:
660660
if name is None:
661661
name = self.name() + '_clone_for_tests'
662662
logging.info("Clone VM")

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ quote-style = "preserve"
5151
[tool.ruff.lint]
5252
select = [
5353
"D", # pydocstyle
54+
"FA", # future-annotations
5455
"F", # Pyflakes
5556
"I", # isort
5657
"SLF", # flake8-self
5758
"SIM", # flake8-simplify
5859
"UP006", # non-pep585-annotation
5960
"UP007", # non-pep604-annotation-union
61+
"UP037", # quoted-annotation
6062
]
6163
# don't use some of the default D and SIM rules
6264
ignore = [

0 commit comments

Comments
 (0)