# Tryton Language Server

**URL:** <https://discuss.tryton.org/t/tryton-language-server/6837>\
**Category:** Ideas\
**Created:** [January 3, 2024, 9:09pm UTC](https://discuss.tryton.org/t/tryton-language-server/6837 "2024-01-03T21:09:36Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 9, 2025, 11:52pm UTC](https://discuss.tryton.org/t/tryton-language-server/6837/21 "2025-05-09T23:52:31Z")

</div>

Here is a first iteration that implement the register in `tryton.cfg`: [Use `tryton.cfg` to register in the Pool (!2392) · Merge requests · Tryton / Tryton · GitLab](https://foss.heptapod.net/tryton/tryton/-/merge_requests/2392)

---

<div class="post-metadata">

**Author:** ![htgoebel](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/htgoebel/32/1256_2.png) [@htgoebel](https://discuss.tryton.org/u/htgoebel)\
**Post date:** [May 13, 2025, 3:54pm UTC](https://discuss.tryton.org/t/tryton-language-server/6837/22 "2025-05-13T15:54:47Z")

</div>

> [@albert](#):
>
> I think we should strive to make module development in Tryton easier, not harder. It is already complex enough for newcomers.

I fully agree with albert.

One of the major benefits of Python is the ease of coding. Typing adds a lot of burden to developers and makes the code much less readable (and thus understandable).

Adding typing to the core modules might be a good idea (as adding typing to important Python packages), but requiring it for custom modules is not.

---

<div class="post-metadata">

**Author:** ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)\
**Post date:** [May 13, 2025, 4:27pm UTC](https://discuss.tryton.org/t/tryton-language-server/6837/23 "2025-05-13T16:27:53Z")

</div>

> [@ced](#):
>
> I think this should be solved like this:
> 
> ```auto
> from typing import cast
> 
> class Party(metaclass=PoolMeta):
> __name__ = 'party.party'
> 
> PartyType = type[Party]
> 
> class Custom(Model):
> ...
> 
> def func(self):
> pool = Pool()
> Party = cast(PartyType, pool.get('party.party'))
> ...
> 
> ```
> 
> with `Pool.get` typed like:
> 
> ```auto
> class Pool:
> ....
> def get(self, name: str, type:str = 'model') -> type[Any]:
> ...
> 
> ```

I have a better design which will prevent to import at runtime more types by removing the usage of `cast`:

```auto
from typing import TYPE_CHECKING

if TYPE_CHECKING:
    class Party(metaclass=PoolMeta):
        __name__ = 'party.party'

    PartyType = type[Party]

class Custom(Model):
    ...

    def func(self):
        pool = Pool()
        Party: PartyType = pool.get('party.party')
        ...

```

And maybe it will be possible to add to mypy a check that the ` __name__ ` of `PartyType` is the same as the string passed to `Pool.get`.

[Previous page](https://discuss.tryton.org/t/tryton-language-server/6837.md?page=1)
