home.social

#strongtyping — Public Fediverse posts

Live and recent posts from across the Fediverse tagged #strongtyping, aggregated by home.social.

fetched live
  1. I have a script called pyfix which runs mypy and ruff to

    - have strong typing
    - have a fixed and orderly import order
    - have the file always formatted in the same way
    - detect programming errors and redundancies.

    Now I am working on gitlogui (codeberg.org/harald/gitlogui) the main script of which I called glu. So I am running

    pyfix glu

    all the time, which reads funny. 😀

    #python #gitlogui #mypy #ruff #strongTyping #linting

  2. Nice one. Type hints in Python allow to list a number of literal values, similar to TypeScript union types and the syntax is actually somewhat more explicit.

    To implement page up/down in codeberg.org/harald/gitlogui I have now:

    def doPage(self, factor: Literal[-1] | Literal[1]) -> None:
    step = factor * int(self.pageSize.get())
    ...

    and I can be sure, when using mypy, that doPage is only ever called with either -1 or 1.

    #python #typehint #strongTyping #gitlogui

  3. Grmbl.😩

    Implementing an object graph with with loops.

    After setup, it needs additional initialization.

    The fields getting set will not change again. Ideally would be final (Java, or readonly in TypeScript). And I don't want an "if (bla!=null)" where ever access I them.

    In my ideal solution this would be guarded by the type system where the nodes, once initialized, change type. I know roughly how it could be done, but its weird and cumbersome. 😕

    #Java #final #datastructure #strongTyping

  4. Just updated the Database App Modules tutorial in the Kitten documentation to fix a few bugs, update to latest Kitten syntax, and improve the instructions:

    kitten.small-web.org/tutorials

    (Database app modules are special app modules¹ that let you create strongly-typed JavaScript databases² in your Small Web³ apps.)

    Enjoy!

    :kitten:💕

    ¹ kitten.small-web.org/reference
    ² codeberg.org/small-tech/jsdb#r
    ³ ar.al/2024/06/24/small-web-com

    #Kitten #DatabaseAppModules #AppModules #tutorial #SmallWeb #SmallTech #web #dev #JSDB #JavaScriptDatabase #JavaScript #database #web #dev #NodeJS #strongTyping