Skip to content

Conversation

@themisvaltinos
Copy link
Contributor

Fixes an issue in python model's serialization where class dependencies referenced inside __init__ were not added to the serialised env, for example:

class ReferencedClass:
    def __init__(self, value: int):
        self.value = value

    def get_value(self) -> int:
        return self.value

class ClassThatReferencesAnother:
    def __init__(self, x: int):
        self.helper = ReferencedClass(x * 2)

This is because in metaprogramming the build_env() function was skipping all dunder methods including __init__ so the dependencies were never added to the serialized environment.

@themisvaltinos themisvaltinos requested review from a team and eakmanrq February 2, 2026 21:45
@georgesittas
Copy link
Contributor

There may be an edge case where this is breaking, FYI. If __init__ references a global variable, for example, which was previously treated as metadata-only because it appeared elsewhere, now it will be picked up and should not be treated as metadata-only.

Not sure if we can do much about this, just mentioning so that we can defensively mark the PR accordingly.

@georgesittas
Copy link
Contributor

The Windows CI job is failing:

FAILED tests/core/test_context.py::test_requirements - AssertionError: assert {'ipywidgets'...test_package'} == {'ipywidgets'...test_package'}
  
  Extra items in the left set:
  'pendulum'
  
  Full diff:
    {
        'ipywidgets',
        'numpy',
        'pandas',
  +     'pendulum',
        'test_package',
    }
==== 1 failed, 2244 passed, 3 skipped, 7239 warnings in 336.78s (0:05:36) =====

Should we update the test?

@themisvaltinos themisvaltinos force-pushed the themis/metaprogramming_fix branch from 4a57092 to 6e524bb Compare February 3, 2026 12:45
@themisvaltinos themisvaltinos changed the title Fix: Allow init to be walked to track its dependencies Fix!: Allow init to be walked to track its dependencies Feb 3, 2026
@themisvaltinos themisvaltinos merged commit 20e0e25 into main Feb 3, 2026
36 of 38 checks passed
@themisvaltinos themisvaltinos deleted the themis/metaprogramming_fix branch February 3, 2026 16:53
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

Successfully merging this pull request may close these issues.

4 participants