Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

name parameter doesn't apply in theme configuration #287

Open
ovunccetin opened this issue Sep 25, 2024 · 0 comments
Open

name parameter doesn't apply in theme configuration #287

ovunccetin opened this issue Sep 25, 2024 · 0 comments

Comments

@ovunccetin
Copy link

ovunccetin commented Sep 25, 2024

Problem Definition

Theme configuration in pytest-sugar.conf does not apply name parameter.

Example

Configuration file:

[theme]
path=magenta
progressbar=cyan
name=blue

Expected Outcome

All the configuration parameters under theme section must apply.

Actual Outcome

path and progressbar parameters apply (i.e., output colors changed). But the name parameter has no effect and hence the output color is unchanged.

Cause

Starting from the following line, the fields of the Theme class is traversed and the corresponding values read from the configuration.

fields: Tuple[dataclasses.Field, ...] = dataclasses.fields(Theme)

However, the name field does not have a type annotation (see below line). So, it doesn't returned in the field list of the Theme class. Therefore, it is ignored and not looked up in the configuration.

name = None

Solution

Add a type annotation to the name field as follows:

class Theme:
    ...
    name: Optional[str] = None
    ...
@ovunccetin ovunccetin changed the title Cannot set name attribute in theme configuration name parameter doesn't apply in theme configuration Sep 25, 2024
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

No branches or pull requests

1 participant