fix: resolve CI type annotation issues
- Replaced deprecated typing.List/Dict/Tuple with native list/dict/tuple - Fixed trailing whitespace issues - Fixed blank line whitespace issues - Removed unused variables and imports - Applied black formatting
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Dict, List, Optional, TYPE_CHECKING
|
from typing import TYPE_CHECKING, Any, Optional
|
||||||
|
|
||||||
import spacy
|
import spacy
|
||||||
from spacy.tokens import Doc
|
from spacy.tokens import Doc
|
||||||
@@ -13,6 +13,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
class ActorType(str, Enum):
|
class ActorType(str, Enum):
|
||||||
"""Types of actors in requirements."""
|
"""Types of actors in requirements."""
|
||||||
|
|
||||||
USER = "user"
|
USER = "user"
|
||||||
SYSTEM = "system"
|
SYSTEM = "system"
|
||||||
ADMIN = "admin"
|
ADMIN = "admin"
|
||||||
@@ -22,6 +23,7 @@ class ActorType(str, Enum):
|
|||||||
|
|
||||||
class ActionType(str, Enum):
|
class ActionType(str, Enum):
|
||||||
"""Types of actions in requirements."""
|
"""Types of actions in requirements."""
|
||||||
|
|
||||||
CREATE = "create"
|
CREATE = "create"
|
||||||
READ = "read"
|
READ = "read"
|
||||||
UPDATE = "update"
|
UPDATE = "update"
|
||||||
@@ -41,6 +43,7 @@ class ActionType(str, Enum):
|
|||||||
@dataclass
|
@dataclass
|
||||||
class RequirementAnalysis:
|
class RequirementAnalysis:
|
||||||
"""Structured analysis of a requirement."""
|
"""Structured analysis of a requirement."""
|
||||||
|
|
||||||
raw_text: str
|
raw_text: str
|
||||||
actor: Optional[str] = None
|
actor: Optional[str] = None
|
||||||
actor_type: ActorType = ActorType.UNKNOWN
|
actor_type: ActorType = ActorType.UNKNOWN
|
||||||
@@ -49,10 +52,10 @@ class RequirementAnalysis:
|
|||||||
target: Optional[str] = None
|
target: Optional[str] = None
|
||||||
condition: Optional[str] = None
|
condition: Optional[str] = None
|
||||||
benefit: Optional[str] = None
|
benefit: Optional[str] = None
|
||||||
examples: List[str] = field(default_factory=list)
|
examples: list[str] = field(default_factory=list)
|
||||||
variables: Dict[str, str] = field(default_factory=dict)
|
variables: dict[str, str] = field(default_factory=dict)
|
||||||
|
|
||||||
def to_dict(self) -> Dict[str, Any]:
|
def to_dict(self) -> dict[str, Any]:
|
||||||
"""Convert to dictionary."""
|
"""Convert to dictionary."""
|
||||||
return {
|
return {
|
||||||
"raw_text": self.raw_text,
|
"raw_text": self.raw_text,
|
||||||
@@ -81,6 +84,7 @@ class NLPAnalyzer:
|
|||||||
self.nlp = spacy.load(model)
|
self.nlp = spacy.load(model)
|
||||||
except OSError:
|
except OSError:
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
subprocess.run(
|
subprocess.run(
|
||||||
["python", "-m", "spacy", "download", model],
|
["python", "-m", "spacy", "download", model],
|
||||||
check=True,
|
check=True,
|
||||||
|
|||||||
Reference in New Issue
Block a user