From: Axy Date: Tue, 13 Jan 2026 17:32:02 +0000 (+0100) Subject: Docstrings and type hints X-Git-Url: https://git.uwuaxy.net/sitemap.xml?a=commitdiff_plain;h=HEAD;p=axy%2Fft%2Fpython04.git Docstrings and type hints --- diff --git a/ex0/ft_ancient_text.py b/ex0/ft_ancient_text.py index c924fb9..f9f44cc 100644 --- a/ex0/ft_ancient_text.py +++ b/ex0/ft_ancient_text.py @@ -1,7 +1,13 @@ import os -def main(): +def main() -> None: + """ + Recovers an ancient data fragment from the storage vault. + + Reads from 'ancient_fragment.txt' and displays its content formatted + according to archive protocols. Handles missing storage vaults gracefully. + """ filename = "ancient_fragment.txt" print("=== CYBER ARCHIVES - DATA RECOVERY SYSTEM ===") print(f"Accessing Storage Vault: {filename}") diff --git a/ex1/ft_archive_creation.py b/ex1/ft_archive_creation.py index 3e9e1be..989a8ed 100644 --- a/ex1/ft_archive_creation.py +++ b/ex1/ft_archive_creation.py @@ -1,4 +1,10 @@ -def main(): +def main() -> None: + """ + Creates a new archive entry with preservation protocols. + + Establishes 'new_discovery.txt' and inscribes critical data entries + including quantum algorithms and efficiency metrics using write mode. + """ filename = "new_discovery.txt" print("=== CYBER ARCHIVES - PRESERVATION SYSTEM ===") print(f"Initializing new storage unit: {filename}") diff --git a/ex2/ft_stream_management.py b/ex2/ft_stream_management.py index 3f4b039..3642b99 100644 --- a/ex2/ft_stream_management.py +++ b/ex2/ft_stream_management.py @@ -1,7 +1,13 @@ import sys -def main(): +def main() -> None: + """ + Manages communication channels for the Cyber Archives. + + Demonstrates usage of standard input (stdin), standard output (stdout), + and standard error (stderr) to route messages and alerts appropriately. + """ print("=== CYBER ARCHIVES - COMMUNICATION SYSTEM ===") arch_id = input("Input Stream active. Enter archivist ID: ") diff --git a/ex3/ft_vault_security.py b/ex3/ft_vault_security.py index 008ede9..5e98215 100644 --- a/ex3/ft_vault_security.py +++ b/ex3/ft_vault_security.py @@ -1,4 +1,11 @@ -def main(): +def main() -> None: + """ + Demonstrates secure vault access using context managers. + + Uses the 'with' statement to ensure safe file operations for both + reading classified data and preserving new security protocols, + guaranteeing resources are properly released. + """ print("=== CYBER ARCHIVES - VAULT SECURITY SYSTEM ===") print("Initiating secure vault access...") print("Vault connection established with failsafe protocols") diff --git a/ex4/ft_crisis_response.py b/ex4/ft_crisis_response.py index ce0e6cf..6353f49 100644 --- a/ex4/ft_crisis_response.py +++ b/ex4/ft_crisis_response.py @@ -1,7 +1,16 @@ import os -def crisis_handler(filename): +def crisis_handler(filename: str) -> None: + """ + Handles archive access attempts and manages potential crises. + + Args: + filename (str): The name of the file (vault) to access. + + Handles FileNotFoundError and PermissionError with appropriate + response protocols. + """ # Determine log prefix if filename == "standard_archive.txt": print(f"ROUTINE ACCESS: Attempting access to '{filename}'...") @@ -24,7 +33,13 @@ def crisis_handler(filename): print("STATUS: Crisis handled") -def main(): +def main() -> None: + """ + Executes a simulation of various crisis scenarios. + + Tests the crisis_handler against missing files, security violations, + and standard access to ensure system stability. + """ print("=== CYBER ARCHIVES - CRISIS RESPONSE SYSTEM ===") # Scenario 1: Missing Archive