# location

URL: /patitas/api/location/
Section: api
Description: Source location tracking for error messages and debugging.

Provides SourceLocation dataclass for tracking positions in source text.
Used throughout Patitas for error messages, AST nodes, and debugging.

Thread Safety:
SourceLocation is frozen (immutable) and safe to share across threads.

---

> For a complete page index, fetch /patitas/llms.txt.

Open LLM text
(/patitas/api/location/index.txt)

Share with AI

Ask Claude
(https://claude.ai/new?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flocation%2Findex.txt)

Ask ChatGPT
(https://chatgpt.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flocation%2Findex.txt)

Ask Gemini
(https://gemini.google.com/app?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flocation%2Findex.txt)

Ask Copilot
(https://copilot.microsoft.com/?q=Please%20help%20me%20understand%20this%20documentation%3A%20%2Fpatitas%2Fapi%2Flocation%2Findex.txt)

Module

#
`location`

Source location tracking for error messages and debugging.

Provides SourceLocation dataclass for tracking positions in source text.
Used throughout Patitas for error messages, AST nodes, and debugging.

Thread Safety:

SourceLocation is frozen (immutable) and safe to share across threads.

1Class

## Classes

`SourceLocation`

10

▼

#### Attributes

Name
Type
Description

`lineno`

`int`

—

`col_offset`

`int`

—

`offset`

`int`

—

`end_offset`

`int`

—

`end_lineno`

`int | None`

—

`end_col_offset`

`int | None`

—

`source_file`

`str | None`

—

#### Methods

`span_to`

1

`SourceLocation (/patitas/api/location/#SourceLocation)`

▼

Create a new location spanning from this location to end.

`def span_to(self, end: SourceLocation) -> SourceLocation`

##### Parameters

Name
Type
Description

`end`
`—`

Ending location

##### Returns

`SourceLocation (/patitas/api/location/#SourceLocation)`

New SourceLocation with this start and end's end positions

`unknown`

0

`SourceLocation (/patitas/api/location/#SourceLocation)`

▼

Create an unknown/placeholder location.

Use for AST nodes created syntheticall…

classmethod

`def unknown(cls) -> SourceLocation`

Create an unknown/placeholder location.

Use for AST nodes created synthetically or when location is unavailable.

##### Returns

`SourceLocation (/patitas/api/location/#SourceLocation)`

Internal Methods
1

▼

`__str__`

0

`str`

▼

Format location for error messages.

`def __str__(self) -> str`

##### Returns

`str`

Formatted string like "file.md:10:5" or "10:5"
