Fix typing in resource_agent package
(cherry picked from commit f1b28218ff9ebfee2c02cb278fc3090fa5524938)
This commit is contained in:
parent
9d607800a9
commit
baa1a768c9
147
Fix-typing-in-resource_agent-package.patch
Normal file
147
Fix-typing-in-resource_agent-package.patch
Normal file
@ -0,0 +1,147 @@
|
||||
From 5fe9bf04c46bfcbb4008d8d2a51b74c6c1693ec3 Mon Sep 17 00:00:00 2001
|
||||
From: rpm-build <rpm-build>
|
||||
Date: Tue, 22 Aug 2023 18:25:34 +0800
|
||||
Subject: [PATCH] Fix typing in resource_agent package
|
||||
|
||||
---
|
||||
mypy.ini | 10 +++++-----
|
||||
pcs/lib/resource_agent/error.py | 4 ++--
|
||||
pcs/lib/resource_agent/facade.py | 12 +++++++-----
|
||||
pcs/lib/resource_agent/types.py | 4 ++--
|
||||
4 files changed, 16 insertions(+), 14 deletions(-)
|
||||
|
||||
diff --git a/mypy.ini b/mypy.ini
|
||||
index f34b513..a3f7d07 100644
|
||||
--- a/mypy.ini
|
||||
+++ b/mypy.ini
|
||||
@@ -48,19 +48,19 @@ disallow_untyped_defs = True
|
||||
# this is a temporary solution for legacy code
|
||||
disallow_untyped_defs = False
|
||||
|
||||
-[mypy-pcs.common.ssl]
|
||||
+[mypy-pcs.common.services.*]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
-[mypy-pcs.common.types]
|
||||
+[mypy-pcs.common.ssl]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
-[mypy-pcs.common.validate]
|
||||
+[mypy-pcs.common.types]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
-[mypy-pcs.common.services.*]
|
||||
+[mypy-pcs.common.validate]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
@@ -113,7 +113,7 @@ disallow_untyped_defs = True
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
-[mypy-pcs.lib.resource_agent]
|
||||
+[mypy-pcs.lib.resource_agent.*]
|
||||
disallow_untyped_defs = True
|
||||
disallow_untyped_calls = True
|
||||
|
||||
diff --git a/pcs/lib/resource_agent/error.py b/pcs/lib/resource_agent/error.py
|
||||
index d417833..f61f196 100644
|
||||
--- a/pcs/lib/resource_agent/error.py
|
||||
+++ b/pcs/lib/resource_agent/error.py
|
||||
@@ -17,13 +17,13 @@ class AgentNameGuessFoundMoreThanOne(ResourceAgentError):
|
||||
self.names_found = names_found
|
||||
|
||||
@property
|
||||
- def searched_name(self):
|
||||
+ def searched_name(self) -> str:
|
||||
return self.agent_name
|
||||
|
||||
|
||||
class AgentNameGuessFoundNone(ResourceAgentError):
|
||||
@property
|
||||
- def searched_name(self):
|
||||
+ def searched_name(self) -> str:
|
||||
return self.agent_name
|
||||
|
||||
|
||||
diff --git a/pcs/lib/resource_agent/facade.py b/pcs/lib/resource_agent/facade.py
|
||||
index 4dbb59b..d5a28f3 100644
|
||||
--- a/pcs/lib/resource_agent/facade.py
|
||||
+++ b/pcs/lib/resource_agent/facade.py
|
||||
@@ -1,6 +1,6 @@
|
||||
from collections import defaultdict
|
||||
from dataclasses import replace as dc_replace
|
||||
-from typing import Dict, Iterable, List, Optional, Set
|
||||
+from typing import Dict, Iterable, List, Optional, Set, cast
|
||||
|
||||
from pcs.common import reports
|
||||
from pcs.lib import validate
|
||||
@@ -12,6 +12,7 @@ from .name import name_to_void_metadata
|
||||
from .ocf_transform import ocf_version_to_ocf_unified
|
||||
from .pcs_transform import get_additional_trace_parameters, ocf_unified_to_pcs
|
||||
from .types import (
|
||||
+ FakeAgentName,
|
||||
ResourceAgentMetadata,
|
||||
ResourceAgentName,
|
||||
ResourceAgentParameter,
|
||||
@@ -154,7 +155,7 @@ class ResourceAgentFacade:
|
||||
return validators
|
||||
|
||||
@property
|
||||
- def _validator_option_type(self):
|
||||
+ def _validator_option_type(self) -> str:
|
||||
return "stonith" if self.metadata.name.is_stonith else "resource"
|
||||
|
||||
def _get_all_params_deprecated_by(self) -> Dict[str, Set[str]]:
|
||||
@@ -185,7 +186,7 @@ class ResourceAgentFacadeFactory:
|
||||
) -> None:
|
||||
self._runner = runner
|
||||
self._report_processor = report_processor
|
||||
- self._fenced_metadata = None
|
||||
+ self._fenced_metadata: Optional[ResourceAgentMetadata] = None
|
||||
|
||||
def facade_from_parsed_name(
|
||||
self, name: ResourceAgentName
|
||||
@@ -226,7 +227,7 @@ class ResourceAgentFacadeFactory:
|
||||
)
|
||||
return ResourceAgentFacade(metadata, additional_parameters)
|
||||
|
||||
- def _get_fenced_parameters(self):
|
||||
+ def _get_fenced_parameters(self) -> List[ResourceAgentParameter]:
|
||||
if self._fenced_metadata is None:
|
||||
agent_name = ResourceAgentName(
|
||||
const.FAKE_AGENT_STANDARD, None, const.PACEMAKER_FENCED
|
||||
@@ -237,7 +238,8 @@ class ResourceAgentFacadeFactory:
|
||||
parse_metadata(
|
||||
agent_name,
|
||||
load_fake_agent_metadata(
|
||||
- self._runner, agent_name.type
|
||||
+ self._runner,
|
||||
+ cast(FakeAgentName, agent_name.type),
|
||||
),
|
||||
)
|
||||
)
|
||||
diff --git a/pcs/lib/resource_agent/types.py b/pcs/lib/resource_agent/types.py
|
||||
index ffa5a51..d045e01 100644
|
||||
--- a/pcs/lib/resource_agent/types.py
|
||||
+++ b/pcs/lib/resource_agent/types.py
|
||||
@@ -26,11 +26,11 @@ class ResourceAgentName:
|
||||
return ":".join(filter(None, [self.standard, self.provider, self.type]))
|
||||
|
||||
@property
|
||||
- def is_pcmk_fake_agent(self):
|
||||
+ def is_pcmk_fake_agent(self) -> bool:
|
||||
return self.standard == _FAKE_AGENT_STANDARD
|
||||
|
||||
@property
|
||||
- def is_stonith(self):
|
||||
+ def is_stonith(self) -> bool:
|
||||
return self.standard == "stonith"
|
||||
|
||||
def to_dto(self) -> ResourceAgentNameDto:
|
||||
--
|
||||
2.41.0
|
||||
|
||||
6
pcs.spec
6
pcs.spec
@ -1,6 +1,6 @@
|
||||
Name: pcs
|
||||
Version: 0.11.2
|
||||
Release: 2
|
||||
Release: 3
|
||||
License: GPLv2 and BSD-2-Clause and ASL 2.0 and MIT
|
||||
URL: https://github.com/ClusterLabs/pcs
|
||||
Summary: Pacemaker Configuration System
|
||||
@ -41,6 +41,7 @@ Patch1: fix-backend-parameter-all-in-cluster-destroy.patch
|
||||
Patch2: bz2093935-01-Python-3.11-related-fixes.patch
|
||||
Patch3: Support-for-openEuler.patch
|
||||
Patch4: Adjust-regex-to-support-json-2.6.3-error.patch
|
||||
Patch5: Fix-typing-in-resource_agent-package.patch
|
||||
# git for patches
|
||||
BuildRequires: git-core
|
||||
BuildRequires: make
|
||||
@ -403,6 +404,9 @@ run_all_tests
|
||||
%license pyagentx_LICENSE.txt
|
||||
|
||||
%changelog
|
||||
* Wed Aug 23 2023 jiangxinyu <jiangxinyu@kylinos.cn> - 0.11.2-3
|
||||
- Fix typing in resource_agent package
|
||||
|
||||
* Mon Aug 07 2023 bizhiyuan <bizhiyuan@kylinos.cn> - 0.11.2-2
|
||||
- Adjust regex pattern for ruby to support json 2.6.3 build error
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user