Skip to content

doc/python/lint.md has identical good and bad code snippets for ruff linting examples 2 and 3 #5

Description

@dcabral00

The examples numbered 2 and 3 under the section "Ruff Formatting" are identical. It is unclear which one is good and which one is bad practice for clear 2) "Error Handling" and 3) "Function Calls with Named Parameters". The affected examples are listed below:

# Example 2: Error Handling
# Bad - Exception types are hard to read and modify
try:
    process_data()
except (
    ValueError,
    TypeError,
    KeyError,
    DatabaseError,
    NetworkTimeout,
    ValidationError,
) as e:
    log_error(e)

# Good - Each exception is clear and git diffs will show exactly what changed
try:
    process_data()
except (
    ValueError,
    TypeError,
    KeyError,
    DatabaseError,
    NetworkTimeout,
    ValidationError,
) as e:
    log_error(e)

# Example 3: Function Calls with Named Parameters
# Bad - Parameter names and values are hard to scan
create_user(
    username="johndoe",
    email="john@example.com",
    role="admin",
    department="engineering",
    active=True,
    send_welcome_email=True,
)

# Good - Each parameter is clearly visible and self-documenting
create_user(
    username="johndoe",
    email="john@example.com",
    role="admin",
    department="engineering",
    active=True,
    send_welcome_email=True,
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions