enthought / enthought/envisage
query evaluation in get_service(s) omits lazy population of default traits
- Dominant language
- Python
- Stars
- 89
- Forks
- 27
- Avg merge
- 14h 48m
- Merged PRs (30d)
- 7
Description
Here is one example to reproduce the bug:
```
from envisage.api import Application
from traits.api import Interface, provides, HasTraits, Str, Int, HasStrictTraits
class IPlumber(Interface):
""" What plumbers do! """
# The plumber's name.
name = Str
# The plumber's location.
location = Str
# The price per hour (in say, Estonian Krooni ;^)
price = Int
def fix_leaking_pipe(self, pipe):
""" Fix a leaking pipe! """
@provides(IPlumber)
class Plumber(HasTraits):
""" An actual plumber implementation! """
# The plumber's name.
name = Str
# The plumber's location.
location = Str
# The price per hour (in say, Estonian Krooni ;^)
price = Int
def fix_leaking_pipe(self, pipe):
""" Fix a leaking pipe! """
print('fixed!')
@provides(IPlumber)
class Foo(HasTraits):
foo = Int
price = Int(20)
if __name__ == '__main__':
application = Application()
fred = Plumber()
foo = Foo()
fred_id = application.register_service(IPlumber, fred)
foo_id = application.register_service(IPlumber, foo)
obj = application.get_services(IPlumber, 'price<30')
print(obj)
```
and the problematic code: https://github.com/enthought/envisage/blob/57338fcb0ea69c75bc3c86de18a5967d8e78c6c1/envisage/service_registry.py#L191-L198
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with envisage/service_registry.py at the linked lines 191-198 and run the reproduction from the issue. Trace how get_services evaluates the `price<30` query before default Traits values are populated. Done means the query includes the Foo service with its default price, with the existing service lookup behavior preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100