Skip to content

[FIX] xml-double-quotes-py: fix tag detection and report exact attrib…#188

Merged
moylop260 merged 1 commit intoOCA:mainfrom
vauxoo-dev:fix-double-quotes2-moy
Apr 29, 2026
Merged

[FIX] xml-double-quotes-py: fix tag detection and report exact attrib…#188
moylop260 merged 1 commit intoOCA:mainfrom
vauxoo-dev:fix-double-quotes2-moy

Conversation

@moylop260
Copy link
Copy Markdown
Collaborator

@moylop260 moylop260 commented Apr 29, 2026

Previously, NodeContent._read_node failed to identify the start of an XML tag when it appeared after other content on the same line (e.g. <li>text<strong) or spanned multiple lines. This caused xml-double-quotes-py to miss elements in those layouts.

Additionally, the error line number was wrong: lxml's sourceline points to the end of the opening tag, not the line of the specific attribute that triggers the warning.

Changes:

  • NodeContent.__init__ now accepts an optional locator (XMLStartTagLocator). When provided, it is used as the authoritative source for the tag start position and line, avoiding fragile line-by-line heuristics.
  • A regex backward-scan fallback is kept for callers that do not supply a locator.
  • check_xml_double_quotes_py passes the already-cached locator (via _get_tag_locator) to NodeContent, and uses locator.get_attr() to report the exact line of the offending attribute instead of elem.sourceline.
  • Added regression test test_xml_double_quotes_py_reports_correct_line_for_inline_and_multiline_tags to tests/test_node_xml.py.

Using IA with Claude

…ute line

Previously, `NodeContent._read_node` failed to identify the start
of an XML tag when it appeared after other content on the same line
(e.g. `<li>text<strong`) or spanned multiple lines. This caused
`xml-double-quotes-py` to miss elements in those layouts.

Additionally, the error line number was wrong: lxml's `sourceline`
points to the *end* of the opening tag, not the line of the
specific attribute that triggers the warning.

Changes:
- `NodeContent.__init__` now accepts an optional `locator`
  (`XMLStartTagLocator`). When provided, it is used as the
  authoritative source for the tag start position and line,
  avoiding fragile line-by-line heuristics.
- A regex backward-scan fallback is kept for callers that do not
  supply a locator.
- `check_xml_double_quotes_py` passes the already-cached locator
  (via `_get_tag_locator`) to `NodeContent`, and uses
  `locator.get_attr()` to report the exact line of the offending
  attribute instead of `elem.sourceline`.
- Added regression test
  `test_xml_double_quotes_py_reports_correct_line_for_inline_and_multiline_tags`
  to `tests/test_node_xml.py`.
@moylop260 moylop260 merged commit 9462894 into OCA:main Apr 29, 2026
18 of 20 checks passed
@moylop260 moylop260 deleted the fix-double-quotes2-moy branch April 29, 2026 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant