Inline ignore comments let you suppress symbol-count violations from inside the module itself using a # psl: ignore comment.


Only symbol-count Honors Inline Ignore

symbol-count is the one rule type that reads .py files, so it is the only one that can see an inline comment. The other three types — directory-exists, allowed-children, and mirror — match directories, not files, so there is no line to attach a marker to. A # psl: ignore comment has no effect on them; scope those rules out with exclude or a narrower within instead.

Because symbol-count reports at the level of a whole module, an inline ignore is file-scoped: it suppresses the targeted rule for the entire file, wherever the comment appears.


Ignore All Rules in a File

A bare # psl: ignore (no brackets) suppresses every psl rule for the file it appears in:

# psl: ignore
class Order: ...
class OrderLine: ...

Both classes live in one module, and no symbol-count rule will flag the file. This is the broadest form of suppression — use it sparingly.


Ignore a Specific Rule

To suppress only one rule, name it inside brackets:

# psl: ignore[one-class-per-domain-module]

Only one-class-per-domain-module is skipped for this file. Any other symbol-count rule that matches the file still reports.

The name must match the name field in your config:

rules:
  - name: one-class-per-domain-module   # This is the name to use in the ignore comment
    type: symbol-count
    within: src/contexts/{ctx}/domain/**
    symbol: class
    max: 1
    ignore_files: [__init__.py]

Ignore Multiple Specific Rules

List several rule names inside the brackets, separated by commas:

# psl: ignore[one-class-per-domain-module, one-error-per-file]

Both rules are suppressed for the file. Whitespace around the commas is stripped, so [a,b] and [a, b] are equivalent.


Match by Rule Name or Checklist ID

The token inside the brackets matches either the full rule name or its bare id prefix — the segment before the first hyphen. A rule named B26-count is therefore suppressed by both of these:

# psl: ignore[B26-count]
# psl: ignore[B26]

This lets you reference a rule by its short checklist id without repeating the full descriptive name.


The Marker Must Be a Real Comment

Only genuine # comment tokens are scanned. A marker that appears inside a string literal or docstring suppresses nothing:

"""
Example: write # psl: ignore to skip a file.   <- not a comment, has no effect
"""
class Order: ...
class OrderLine: ...

The ignore keyword must also be a complete token, so # psl: ignoreable is not read as a blanket ignore.


Practical Examples

Allowing an aggregate root to sit next to its entities in one module:

# src/contexts/orders/domain/entities/order.py
# psl: ignore[one-class-per-domain-module]

class Order: ...
class OrderLine: ...

Skipping every rule for a generated or vendored module:

# src/contexts/orders/domain/entities/schema_generated.py
# psl: ignore

Suppressing one rule by its checklist id while leaving others active:

# src/contexts/orders/domain/errors/order_not_found_error.py
# psl: ignore[B26]

class OrderNotFoundError(Exception): ...
class OrderAlreadyExistsError(Exception): ...

With the ignore in place, the run passes:

$ psl check
No violations found.

Remove the comment and the surplus class is reported at the line where it is defined:

$ psl check
src/contexts/orders/domain/errors/order_not_found_error.py:4
    [one-error-per-file] Each errors module defines a single error class
    2 top-level class definitions found, at most 1 allowed

Found 1 violation(s).

Summary

Topic Detail
Supported rules Only symbol-count honors inline ignore; directory-based rules cannot be suppressed this way.
Scope File-scoped — the comment suppresses the rule for the whole module, wherever it appears in the file.
Blanket form # psl: ignore (no brackets) skips every rule for the file.
Targeted form # psl: ignore[rule-name], or several names as # psl: ignore[a, b].
Token matching The bracket token matches the full rule name or the bare id prefix (segment before the first hyphen).
Real comments only Markers inside strings or docstrings are ignored; the marker must be in a # comment.
Unknown names A name that matches no rule is silently skipped — no error is raised.