File: copilot-codeGeneration-instructions.md

package info (click to toggle)
python-uuid-extension 0.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 176 kB
  • sloc: python: 228; makefile: 2
file content (87 lines) | stat: -rw-r--r-- 2,913 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# GitHub Copilot Code Generation Instructions

## Python Code Style: `.py` Files
- Follow these guidelines for all Python files.

### General
- Minimum Python Version: `3.10`.

### Formatting
- Adhere to the `PEP8` standard.
- Use `snake_case` for variable and function names.
- Use `PascalCase` for class names.
- Enclose strings in `double quotes`.
- Indent code using `4 spaces`.
- Use `typing` annotations wherever possible. Prefer built-in types (e.g., `list`, `dict`, `tuple`) over imports from the `typing` module.
- Avoid unnecessary blank lines and trailing whitespace.
- Limit line length to `80 characters`. Use line breaks for longer lines, maintaining proper indentation.
- Ensure consistent formatting across the codebase for readability and maintainability.
- Regularly review and update formatting rules to align with evolving project requirements.

### Linting
- Use `ruff` as the primary linter.
- Check for `[tool.ruff.lint]` entries in `pyproject.toml` or rules in `ruff.toml`.
- Follow rule `EM101`: Exception messages must not use string literals directly, assign to a variable first.
- Resolve all linting violations before committing code.
- If `ruff` is unavailable, use an alternative linter that supports `PEP8` compliance.
- Regularly update linting configurations to align with project standards.
- Document custom linting rules or exceptions in the repository.

### Example
```python
def calculate_average(numbers: list[float]) -> float:
    """
    Calculate the average of a list of numbers.

    Args:
        numbers: List of numerical values

    Returns:
        The average of the input numbers

    Raises:
        ValueError: If the list is empty
    """
    if not numbers:
        msg = "Cannot calculate average of empty list"
        raise ValueError(msg)

    return sum(numbers) / len(numbers)
```


---

## SQL Code Style: `.sql` Files
- Use these guidelines for all SQL files.
- Dialect: `TSQL` for Microsoft SQL Server.

### Formatting
- Use `snake_case` for variable names.
- Write `comma-first` lines.
- Use UPPERCASE for SQL keywords (e.g., SELECT, FROM, WHERE).
- Indent with `4 spaces`, not tabs.
- Add line breaks before each clause (e.g., WHERE, JOIN, GROUP BY).
- Use short but meaningful aliases for table names.
- Include the schema name when referencing tables (e.g., `dbo.table_name`).
- Add comments for complex logic or non-obvious operations.
- Align similar elements vertically for better readability.

#### Example: Comma-First Style
```sql
SELECT
    column_id
  , column_name
FROM dbo.mytable
WHERE 1=1
  AND column_id = 1
```

---

## Markdown Style: `.md` Files
- Improve grammar and clarity when using `/fix` or `improve` commands.
- Ensure concise and professional language.
- Use proper headings and formatting for readability.
- Avoid redundant or overly complex phrasing.
- Regularly review and refine content for accuracy and consistency.