Skip to content
Discussion options

You must be logged in to vote

OK so, it won't be possible to fix this while we keep using ast, but I can imagine a few solutions:

  • we move to a CST parser (Concrete rather than Abstract Syntax Tree), but this is a drastic change so won't happen soon
  • you write a small, custom Griffe extension that converts back values of specific objects to hex
importgriffeclassToHex(griffe.Extension): def__init__(self, objects: list[str]) ->None: self._objects=set(objects) defon_attribute(self, *, attr: griffe.Attribute, **kwargs) ->None: ifattr.pathinself._objects: ifisinstance(attr.value, griffe.ExprConstant): # just to be sureattr.value.value=hex(int(attr.value.

Replies: 1 comment 9 replies

Comment options

You must be logged in to vote
9 replies
@pawamoy
Comment options

@mrossington
Comment options

@mrossington
Comment options

@pawamoy
Comment options

Answer selected bymrossington
@mrossington
Comment options

@pawamoy
Comment options

@pawamoy
Comment options

@pawamoy
Comment options

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
docsImprovements or additions to documentationgriffe extensionCan be solved with a Griffe extension
2 participants
@mrossington@pawamoy