GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tests: example ledger classification no longer depends on the Python … · airmang/python-hwpx@0133e84

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • docs
    • python-example-ledger.json
  • tests
    • test_documentation_code_fences.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/python-example-ledger.json‎

Copy file name to clipboardExpand all lines: docs/python-example-ledger.json
+4-6Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@
167167
"docs/usage.md#89",
168168
"docs/faq.md#2",
169169
"docs/faq.md#4",
170-
"docs/faq.md#5",
171-
"docs/safe-write-contract.md#1"
170+
"docs/faq.md#5"
172171
],
173172
"requiredContext": [
174173
"The listed symbols must already exist with the type and document state described by the surrounding section.",
@@ -244,14 +243,13 @@
244243
],
245244
"docs/faq.md#5": [
246245
"document"
247-
],
248-
"docs/safe-write-contract.md#1": [
249-
"MutationReport"
250246
]
251247
}
252248
},
253249
"context-fragment/illustrative-signature": {
254-
"ids": [],
250+
"ids": [
251+
"docs/safe-write-contract.md#1"
252+
],
255253
"requiredContext": [
256254
"Read the declarations as HwpxDocument method signatures, not as an implementation or standalone program."
257255
]
Collapse file

‎tests/test_documentation_code_fences.py‎

Copy file name to clipboardExpand all lines: tests/test_documentation_code_fences.py
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,31 @@ def _import_roots(node: ast.Import | ast.ImportFrom) -> set[str]:
122122
return {node.module.partition(".")[0]}
123123

124124

125+
class _DropAnnotations(ast.NodeTransformer):
126+
"""Replace every annotation with ``None``. Python 3.14 (PEP 649) gives annotations their own scope, so the
127+
module's symbol table stops seeing names used only there (3.10-3.13 see them): without this the ledger
128+
would depend on the Python that built it. Names used only in annotations are not prior state."""
129+
130+
def visit_arg(self, node: ast.arg) -> ast.arg:
131+
node.annotation = None
132+
return node
133+
134+
def _function(self, node: ast.AST) -> ast.AST:
135+
self.generic_visit(node)
136+
node.returns = None # type: ignore[attr-defined]
137+
return node
138+
139+
visit_FunctionDef = visit_AsyncFunctionDef = _function
140+
141+
def visit_AnnAssign(self, node: ast.AnnAssign) -> ast.AnnAssign:
142+
self.generic_visit(node)
143+
node.annotation = ast.Constant(None)
144+
return node
145+
146+
125147
def _external_names(code: str, example_id: str) -> list[str]:
126-
table = symtable.symtable(code, example_id, "exec")
148+
tree = _DropAnnotations().visit(ast.parse(code, filename=example_id))
149+
table = symtable.symtable(ast.unparse(ast.fix_missing_locations(tree)), example_id, "exec")
127150
return sorted(
128151
symbol.get_name()
129152
for symbol in table.get_symbols()

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.