awesome-copilot/instructions/python.instructions.md
James Montemagno 6fb794bc79
Update development instructions and guidelines (#29)
* Delete outdated development instructions for Next.js + Tailwind and Python; add comprehensive guidelines for PostgreSQL DBA, Angular, ASP.NET REST APIs, Azure Functions with TypeScript, Bicep, Blazor, CMake with vcpkg, C#, .NET MAUI, GenAIScript, Terraform for Azure, localization, and markdown standards.

* Update documentation and prompts for consistency and clarity

- Standardized description formatting in various markdown files to use single quotes.
- Added error handling utility in update-readme.js for safer file operations.
- Improved title extraction logic in update-readme.js to handle frontmatter more robustly.
- Updated chat modes section in README to reflect new emoji and sorted chat mode links.
- Cleaned up various instruction files for better readability and consistency.
- Ensured all markdown files end with a newline for better compatibility with version control.

* Remove standardize-frontmatter.js script

* Add usage instructions for creating and switching chat modes in README.md

* Update README.md generation script to enhance instructions and usage details for custom chat modes

* Update README.md and update-readme.js for improved instruction clarity and consistency

* Refactor README.md links and update readme script for improved clarity and consistency in instructions

* Update README.md and update-readme.js for improved instruction clarity and consistency

* Changing from a patch to regen approach for the readme

* Bit more cleanup for how to show things in the readme

* Adding missing description

* Another missing description

---------

Co-authored-by: Aaron Powell <me@aaron-powell.com>
2025-07-03 11:18:52 +10:00

2.1 KiB

description applyTo
Python coding conventions and guidelines **/*.py

Python Coding Conventions

Python Instructions

  • Write clear and concise comments for each function.
  • Ensure functions have descriptive names and include type hints.
  • Provide docstrings following PEP 257 conventions.
  • Use the typing module for type annotations (e.g., List[str], Dict[str, int]).
  • Break down complex functions into smaller, more manageable functions.

General Instructions

  • Always prioritize readability and clarity.
  • For algorithm-related code, include explanations of the approach used.
  • Write code with good maintainability practices, including comments on why certain design decisions were made.
  • Handle edge cases and write clear exception handling.
  • For libraries or external dependencies, mention their usage and purpose in comments.
  • Use consistent naming conventions and follow language-specific best practices.
  • Write concise, efficient, and idiomatic code that is also easily understandable.

Code Style and Formatting

  • Follow the PEP 8 style guide for Python.
  • Maintain proper indentation (use 4 spaces for each level of indentation).
  • Ensure lines do not exceed 79 characters.
  • Place function and class docstrings immediately after the def or class keyword.
  • Use blank lines to separate functions, classes, and code blocks where appropriate.

Edge Cases and Testing

  • Always include test cases for critical paths of the application.
  • Account for common edge cases like empty inputs, invalid data types, and large datasets.
  • Include comments for edge cases and the expected behavior in those cases.
  • Write unit tests for functions and document them with docstrings explaining the test cases.

Example of Proper Documentation

def calculate_area(radius: float) -> float:
    """
    Calculate the area of a circle given the radius.
    
    Parameters:
    radius (float): The radius of the circle.
    
    Returns:
    float: The area of the circle, calculated as π * radius^2.
    """
    import math
    return math.pi * radius ** 2