Install
$ agentstack add skill-theafh-ai-modules-format-python Open-source listing, not yet scanned by AgentStack. Follow the source repository for install instructions.
Security review
⚠ Flagged1 finding(s); flagged for manual review. · v0.1.0 How review works →
- • Prompt-injection patterns
- • Secret / credential exfiltration
- • Dangerous shell & filesystem operations
- • Untrusted network calls
- • Known-malicious package signatures
- high Dangerous shell/eval execution.
What it can access
- ✓ Network access No
- ● Filesystem access Used
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ● Dynamic code execution Used
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
format_python
Formatting Standards
- Use exactly 4 spaces for indentation (never tabs)
- Use double quotes for all string literals consistently
- Write one import per line, group in order: stdlib → third party → first party → local
- Use
snake_casefor variables/functions,PascalCasefor classes,UPPER_CASEfor constants - Keep lines under 88 characters, break long lines at logical points with proper indentation
Code Quality Standards
- Write valid Python syntax that passes all linter checks
- Use specific exception types like
ValueError,FileNotFoundError - Assign error messages to variables before raising exceptions
- Import only what you use - avoid unused imports, types, or variables
- Use
_for intentionally unused values to prevent F841 errors - Use modern type hints:
dict[str, Any]instead ofDict[str, Any],str | Noneinstead ofOptional[str] - Import types only when needed - prefer built-in types over
typingmodule when possible - Use f-strings for general formatting, use % formatting in logging statements
- Use
is/is notforNonecomparisons, usein/not infor membership testing - Avoid single-letter variable names except for loop counters
- Don't shadow built-in names like
list,dict,str,id,type - Use context managers (
withstatements) for all file operations and resource cleanup - Use
logger = logging.getLogger(__name__)for module-level logging - Use logging instead of print statements for all output
Code Structure
- Follow this exact order: docstring → imports → constants → classes → functions → main guard
- Write functions with single responsibility, clear parameters, and early returns for better readability
- Use clear, descriptive class names; apply proper decorators (
@classmethod,@staticmethod) for class methods - Validate all input parameters when necessary, especially for public functions
Linting Prevention (Critical for LLM Code Generation)
- Write one import per line to prevent E401 multiple imports error
- Import only modules you actively use - remove unused imports immediately to prevent F401 errors
- Omit exception variable name when not using the exception object
- Remove commented-out code and unreachable statements immediately
- Update all class references when renaming to prevent F821 undefined name errors
- Use descriptive class names without "Test" prefix for non-test classes
- Use
is Noneinstead of== Noneto prevent E711 comparison error
Best Practices
- Define named functions instead of lambda assignments for better readability
- Use absolute imports for clarity
- Write one statement per line for maximum readability
- Create variables only when needed; use unique, descriptive names per scope
- Use
isinstance()for type comparisons instead oftype()checks - Use
path.open()instead ofopen(path)when working with Path objects - Use
logger.exception()in except blocks for better error tracking - Validate and sanitize all external inputs
- Use environment variables for sensitive configuration
Error Handling & Resilience
- Always handle exceptions at the appropriate level of abstraction
- Use specific exception types and provide meaningful error messages
- Log errors with sufficient context for debugging
- Implement graceful degradation when possible
- Use try-except-else-finally blocks appropriately
- Re-raise exceptions with
raise ... from eto preserve stack traces - Create custom exception classes for domain-specific errors
Performance & Efficiency
- Use generators for large datasets to conserve memory
- Prefer list comprehensions over explicit loops when readable
- Use
enumerate()instead of manual index tracking - Cache expensive computations when appropriate
- Use
collections.defaultdictandcollections.Counterfor common patterns - Avoid premature optimization; profile before optimizing
- Use
functools.lru_cachefor expensive pure functions
Data Structures & Patterns
- Use dataclasses for simple data containers
- Prefer dictionaries over classes for simple data grouping
- Use
collections.namedtuplefor immutable data structures - Implement
__str__and__repr__methods for custom classes - Use
__slots__for memory-efficient classes with many instances - Prefer composition over inheritance when possible
Type Safety & Documentation
- Use type hints for all function parameters and return values
- Document complex algorithms and business logic
- Use docstrings following PEP 257 conventions
- Include examples in docstrings for complex functions
- Use
typing.Protocolfor structural subtyping - Prefer
typing.Literalfor fixed value sets
Testing & Maintainability
- Write testable code with clear separation of concerns
- Use dependency injection for external dependencies
- Make functions pure when possible (no side effects)
- Use constants for magic numbers and strings
- Keep functions small and focused on single responsibilities
- Use meaningful variable and function names that explain intent
Security & Safety
- Never use
eval()orexec()with user input - Validate and sanitize all external data
- Use
secretsmodule for cryptographic operations - Be cautious with file path operations to prevent directory traversal
- Use parameterized queries for database operations
- Store sensitive data in environment variables or secure vaults
Example
"""Module docstring."""
import logging
from typing import Any
# Constants
DEFAULT_TIMEOUT = 30
logger = logging.getLogger(__name__)
class ExampleClass:
"""Example class demonstrating proper patterns."""
def __init__(self, name: str, value: int | None = None) -> None:
"""Initialize with name and optional value."""
self.name = name
self.value = value
def process_data(self, data: list[dict[str, Any]]) -> bool:
"""Process data and return success status."""
if not data:
return False
for item in data:
if not isinstance(item, dict):
return False
return True
def get_info(self) -> dict[str, Any]:
"""Get class information."""
return {
"name": self.name,
"value": self.value,
"has_value": self.value is not None,
}
def main() -> None:
"""Execute main function."""
example = ExampleClass("test")
result = example.process_data([{"id": 1, "name": "item"}])
logger.info("Result: %s", result)
if __name__ == "__main__":
main()
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: theafh
- Source: theafh/ai-modules
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.