Skip to content

Commit 36d99ad

Browse files
committed
improved indentation and update formatting detection
1 parent af815cd commit 36d99ad

File tree

3 files changed

+52
-24
lines changed

3 files changed

+52
-24
lines changed

python/binaryview.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,12 +2614,12 @@ def add_memory_region(self, name: str, start: int, source: Optional[Union['os.Pa
26142614
26152615
The `source` parameter determines the type:
26162616
2617-
- `os.PathLike` or `str`: File path to be loaded into memory as a `DataMemoryRegion`.
2618-
- `bytes` or `bytearray`: Directly loaded into memory as a `DataMemoryRegion`.
2619-
- `databuffer.DataBuffer`: Loaded as a `DataMemoryRegion`.
2620-
- `fileaccessor.FileAccessor`: Remote proxy source.
2621-
- `BinaryView`: (Reserved for future).
2622-
- `None`: Creates an unbacked memory region (must specify `length`).
2617+
- `os.PathLike` or `str`: File path to be loaded into memory as a `DataMemoryRegion`.
2618+
- `bytes` or `bytearray`: Directly loaded into memory as a `DataMemoryRegion`.
2619+
- `databuffer.DataBuffer`: Loaded as a `DataMemoryRegion`.
2620+
- `fileaccessor.FileAccessor`: Remote proxy source.
2621+
- `BinaryView`: (Reserved for future).
2622+
- `None`: Creates an unbacked memory region (must specify `length`).
26232623
26242624
.. note:: If no flags are specified and the new memory region overlaps with one or more existing regions, the overlapping portions of the new region will inherit the flags of the respective underlying regions.
26252625
@@ -5209,10 +5209,10 @@ def update_analysis_and_wait(self) -> None:
52095209
52105210
**Thread Restrictions**:
52115211
5212-
- **Worker Threads**: This function cannot be called from a worker thread. If called from a worker thread, an error will be
5213-
logged, and the function will return immediately.
5214-
- **UI Threads**: This function cannot be called from a UI thread. If called from a UI thread, an error will be logged, and
5215-
the function will return immediately.
5212+
- **Worker Threads**: This function cannot be called from a worker thread. If called from a worker thread, an error will be
5213+
logged, and the function will return immediately.
5214+
- **UI Threads**: This function cannot be called from a UI thread. If called from a UI thread, an error will be logged, and
5215+
the function will return immediately.
52165216
52175217
:rtype: None
52185218
"""

python/transform.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -447,11 +447,11 @@ class TransformContext:
447447
448448
Each context can have:
449449
450-
- Input data (BinaryView)
451-
- Transform information (name, parameters, results)
452-
- File selection state (available_files, requested_files)
453-
- Parent/child relationships for nested containers
454-
- Extraction status and error messages
450+
- Input data (BinaryView)
451+
- Transform information (name, parameters, results)
452+
- File selection state (available_files, requested_files)
453+
- Parent/child relationships for nested containers
454+
- Extraction status and error messages
455455
456456
Contexts are typically accessed through a ``TransformSession`` rather than created directly.
457457

scripts/check_docstring_formatting.py

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,43 @@ def check_docstring_formatting(docstring):
137137
prev_indent = len(prev_line) - len(prev_line.lstrip())
138138
is_indented_continuation = current_indent > prev_indent
139139

140-
# Special case: >>> code blocks can have output lines between prompts
141-
# If current line is >>> and previous line has same or greater indent (but isn't also >>>),
142-
# it's likely output from previous command
143-
is_code_output = (description == 'code block' and
144-
prev_indent >= 0 and
145-
not prev_line.strip().startswith('>>>') and
146-
not prev_line.strip().startswith('...'))
147-
148-
if not is_prev_list and not is_sphinx_field and not is_indented_continuation and not is_code_output:
140+
# Special case for code blocks (>>>):
141+
if description == 'code block':
142+
# In Python interactive sessions, >>> prompts after output or continuations are normal
143+
# Skip if: previous line is >>> or ..., OR both lines are indented (in code example)
144+
if (prev_line.strip().startswith('...') or
145+
prev_line.strip().startswith('>>>') or
146+
(prev_indent > 0)): # Both lines indented = inside code example
147+
# Don't report this as an issue
148+
break
149+
150+
# Special case for bullet/numbered lists:
151+
# 1. Check if we're continuing a list (prev line is wrapped text from previous bullet)
152+
# 2. Check if we're nested under another list item
153+
is_nested_list = False
154+
if description in ['bullet list item', 'numbered list item']:
155+
# Look back to find context - skip blank lines
156+
for j in range(i - 1, max(0, i - 10), -1):
157+
check_line = lines[j]
158+
if not check_line.strip():
159+
continue # Skip blank lines
160+
check_indent = len(check_line) - len(check_line.lstrip())
161+
162+
# If we find a line at same indent that's also a list item, we're continuing a list
163+
if check_indent == current_indent and any(re.match(p[0], check_line) for p in patterns):
164+
is_nested_list = True # This is a list continuation
165+
break
166+
167+
# If we find a less-indented line that's also a list item, we're nested
168+
if check_indent < current_indent and any(re.match(p[0], check_line) for p in patterns):
169+
is_nested_list = True
170+
break
171+
172+
# If we find a non-list line at current or less indent (intro text), stop looking
173+
if check_indent <= current_indent:
174+
break
175+
176+
if not is_prev_list and not is_sphinx_field and not is_indented_continuation and not is_nested_list:
149177
issues.append((i + 1, f"{description} without blank line before it"))
150178
break # Only report one issue per line
151179

0 commit comments

Comments
 (0)