Skip to content

[Bug]: math_role.options dead code? #21404

@DimitriPapadopoulos

Description

@DimitriPapadopoulos

Bug summary

I don't understand what this piece of code means:

math_role.options = {'fontset': fontset_choice,
'fontsize': validate_float_or_None}

It appears just after the definition of a math_role() function:
def math_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):

Because of that, it is "legal", but it doesn't seem to serve any purpose and is confusing.

Noticed this issue while working on #21402, which is precisely about the incorrectly mutable default value of argument options, so it might be related.

Code for reproduction

 def math_role(role, rawtext, text, lineno, inliner, 
               options={}, content=[]): 
    [...]
 math_role.options = {'fontset': fontset_choice, 
                      'fontsize': validate_float_or_None} 

Actual outcome

Line doesn't have any effect, as far as I can understand:

math_role.options = {'fontset': fontset_choice,
'fontsize': validate_float_or_None}

Expected outcome

Line should be removed:

math_role.options = {'fontset': fontset_choice,
'fontsize': validate_float_or_None}

Operating system

No response

Matplotlib Version

@master

Matplotlib Backend

No response

Python version

No response

Jupyter version

No response

Other libraries

No response

Installation

source

Conda channel

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions