🔍 Code Extractor

class WorkflowStatus

Maturity: 48

An enumeration class that defines the possible status values for workflow cycles, including both review and approval workflows.

File:
/tf/active/vicechatdev/CDocs single class/models/workflow_base.py
Lines:
15 - 22
Complexity:
simple

Purpose

WorkflowStatus provides a type-safe enumeration of all possible states that a workflow cycle can be in. It inherits from both str and Enum, making it compatible with string operations while providing enum benefits like type checking and preventing invalid values. This enum is used to track the lifecycle of review and approval cycles in a document workflow system, with specific statuses for different workflow outcomes (completed for reviews, approved/rejected for approvals).

Source Code

class WorkflowStatus(str, Enum):
    """Status enum for workflow cycles (both review and approval)."""
    PENDING = "PENDING"
    IN_PROGRESS = "IN_PROGRESS"
    COMPLETED = "COMPLETED"  # For Review cycles
    APPROVED = "APPROVED"    # For Approval cycles
    REJECTED = "REJECTED"
    CANCELED = "CANCELED"

Parameters

Name Type Default Kind
bases str, Enum -

Parameter Details

str: First base class - makes enum members behave as strings, allowing direct string comparisons and serialization

Enum: Second base class - provides enumeration functionality with member validation and iteration capabilities

Return Value

Instantiation returns a WorkflowStatus enum member. Each member is both a string and an enum value, so it can be used in string contexts (e.g., comparisons, serialization to JSON) while maintaining type safety. The enum has six possible values: PENDING, IN_PROGRESS, COMPLETED, APPROVED, REJECTED, and CANCELED.

Class Interface

Attributes

Name Type Description Scope
PENDING str Workflow cycle has been created but not yet started class
IN_PROGRESS str Workflow cycle is currently active and being processed class
COMPLETED str Review cycle has been completed successfully (specific to review workflows) class
APPROVED str Approval cycle has been approved (specific to approval workflows) class
REJECTED str Workflow cycle has been rejected (applies to both review and approval workflows) class
CANCELED str Workflow cycle has been canceled before completion class

Dependencies

  • enum

Required Imports

from enum import Enum

Usage Example

from enum import Enum

class WorkflowStatus(str, Enum):
    PENDING = "PENDING"
    IN_PROGRESS = "IN_PROGRESS"
    COMPLETED = "COMPLETED"
    APPROVED = "APPROVED"
    REJECTED = "REJECTED"
    CANCELED = "CANCELED"

# Using the enum
status = WorkflowStatus.PENDING
print(status)  # Output: PENDING
print(status == "PENDING")  # Output: True
print(isinstance(status, str))  # Output: True

# Iterating over all statuses
for status in WorkflowStatus:
    print(status.name, status.value)

# Using in conditionals
if status == WorkflowStatus.PENDING:
    print("Workflow is pending")

# Serialization (works as string)
import json
data = {"status": status}
json_str = json.dumps(data)  # Works because status is a string

# Getting enum from string value
status_from_str = WorkflowStatus("APPROVED")
print(status_from_str == WorkflowStatus.APPROVED)  # Output: True

Best Practices

  • Use WorkflowStatus members instead of raw strings to ensure type safety and prevent typos
  • The enum inherits from str, so it can be directly compared to strings and serialized to JSON without conversion
  • COMPLETED status is specifically for Review cycles, while APPROVED is for Approval cycles - use the appropriate status for the workflow type
  • REJECTED status applies to both review and approval workflows when the workflow is not accepted
  • CANCELED status indicates the workflow was terminated before completion
  • When storing in databases or APIs, the string value will be used automatically due to str inheritance
  • Use WorkflowStatus(value) to convert a string back to the enum type with validation
  • The enum is immutable - members cannot be modified after definition
  • Access enum members using dot notation (WorkflowStatus.PENDING) or by value (WorkflowStatus('PENDING'))
  • Use .name to get the member name as a string and .value to get the associated value

Similar Components

AI-powered semantic similarity - components with related functionality:

  • class AssignmentStatus 81.4% similar

    An enumeration class that defines the possible status values for assignments in a document review/approval workflow.

    From: /tf/active/vicechatdev/CDocs single class/models/workflow_base.py
  • class ContentStatus 72.7% similar

    An enumeration class that defines the possible status values for content generation and editing workflows.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class AnalysisStatus_v1 69.4% similar

    An enumeration class that defines the possible status values for statistical analysis operations.

    From: /tf/active/vicechatdev/smartstat/models.py
  • class AnalysisStatus 66.3% similar

    An enumeration class that defines the possible status states for statistical analysis operations.

    From: /tf/active/vicechatdev/vice_ai/models.py
  • class WorkflowCycleBase 66.3% similar

    Base class for workflow cycles (ReviewCycle and ApprovalCycle) that manages workflow lifecycle, status tracking, and common properties for document review and approval processes.

    From: /tf/active/vicechatdev/CDocs single class/models/workflow_base.py
← Back to Browse