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 — Pretty print getattr as string if possible · mjdhasan/egglog-python@98f8e32

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • python/egglog
    • pretty.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎python/egglog/pretty.py‎

Copy file name to clipboardExpand all lines: python/egglog/pretty.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import ast
88
from collections import Counter, defaultdict
99
from dataclasses import dataclass, field
10-
from typing import TYPE_CHECKING, TypeAlias
10+
from typing import TYPE_CHECKING, TypeAlias, assert_never
1111

1212
import black
1313
import cloudpickle
14-
from typing_extensions import assert_never
1514

1615
from .declarations import *
1716

@@ -475,6 +474,8 @@ def _call_inner( # noqa: C901, PLR0911, PLR0912
475474
case _ if method_name in NAMED_UNARY_METHODS:
476475
return NAMED_UNARY_METHODS[method_name], [non_str_slf, *args]
477476
case "__getattr__":
477+
if isinstance(args[0], LitDecl) and isinstance(args[0].value, str):
478+
return f"{slf}.{args[0].value}"
478479
return "getattr", [non_str_slf, *args]
479480
case _:
480481
return f"{slf}.{method_name}", args

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.