Skip to content

Commit

Permalink
Fix use_330 defaulting to True instead of None
Browse files Browse the repository at this point in the history
  • Loading branch information
Moguri committed Dec 6, 2023
1 parent 1bd1b25 commit 0610e48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion simplepbr/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
from __future__ import annotations

from dataclasses import dataclass, field, InitVar
from dataclasses import (
dataclass,
field,
Field,
InitVar,
MISSING,
)
import builtins
import functools
import math
Expand Down Expand Up @@ -90,6 +96,11 @@ def add_prc_fields(cls: type) -> type:

def factoryfn(attrname: str, attrtype: str, default_value: Any) -> Any:
name=f'simplepbr-{attrname.replace("_", "-")}'
if isinstance(default_value, Field):
if default_value.default_factory is not MISSING:
default_value = default_value.default_factory()
elif default_value.default is not MISSING:
default_value = default_value.default
return prc_types[attrtype](
name=name,
default_value=default_value,
Expand All @@ -99,13 +110,15 @@ def wrap(cls: type) -> type:
annotations = cls.__dict__.get('__annotations__', {})
for attrname, attrtype in annotations.items():
if attrname.startswith('_'):
# Private member, skip
continue

default_value = getattr(cls, attrname)
if attrtype.startswith('Literal') and isinstance(default_value, int):
attrtype = 'int'

if attrtype not in prc_types:
# Not a currently supported type, skip
continue

# pylint:disable-next=invalid-field-call
Expand Down
1 change: 1 addition & 0 deletions tests/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_setup_prc_variables(showbase):
assert pipeline.max_lights == 4
assert not pipeline.use_emission_maps
assert pipeline.msaa_samples == 8
assert not pipeline.use_330


@pytest.mark.parametrize('showbase', ['', 'gl-version 3 2'], indirect=True)
Expand Down

0 comments on commit 0610e48

Please sign in to comment.