GithubHelp home page GithubHelp logo

Type annotations about smart_importer HOT 2 CLOSED

beancount avatar beancount commented on June 16, 2024
Type annotations

from smart_importer.

Comments (2)

johannesjh avatar johannesjh commented on June 16, 2024

Background: I started adding type annotations because I liked them better than comments. Not sure how they can be used in python to verify correctly typed data.

I am honestly not sure about how to follow up on this. E.g.,

  • We could introduce static type checks, either while running the program or during continuous integration. For example, after quick googling, I found mypy, which people are using to perform type checking.
  • I found that some articles argued against static type checks in favor of duck typing. Sure, we could introduce ducky type checks, but they would probably add many lines of code, making refactorings more difficult, without a lot of benefit.
  • Or else we could drop the type declarations altogether and simply throw runtime errors if data does not match the program's expectations. But I like type declarations for documentation purposes.

from smart_importer.

yagebu avatar yagebu commented on June 16, 2024

Afaict setting up static type checking is not trivial since it needs to know the types of structures from the dependencies too. However, if we want any kind of type checking, static is the way to go.

If they're just for documentation purposes, I'd be for having fewer of them and in particular not having them in places where it's absolutely obvious (like transaction being, well, a list of Transaction objects).

from smart_importer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.