Giter Site home page Giter Site logo

Comments (4)

hCraker avatar hCraker commented on June 27, 2024 1

This is a good catch! At this point, I'd suggest making a research to see if there is any practical ways of actually conducting runtime checks for argument types.

I have spent some time looking into this, and the Python developers have made it clear that they don't ever want to enforce typing. Doing so would remove the benefits of Python being dynamically typed (i.e. the flexibility of duck-typing).

I think the easiest way to enforce specific types for our functions would be to check the argument types at the start of the function and return reasonable error messages. This would be a courtesy to our users, and by no means is it currently required. However, it isn't a bad idea to do. My motivation for looking in to type hints was to avoid cryptic error messages when a function fails, and this alternative would accomplish that with a bit more code. I'm open to discussion about it.

Also, I think @anissa111 had some thoughts about type hints would change with a future Python version?

@anissa111 pointed out to me that there are some changes to how type hints are formatted in Python 10, but it appears to be backwards compatible syntax changes. See PEP 604 for more details.

from geocat.

hCraker avatar hCraker commented on June 27, 2024

I now realize that I misunderstood how Python uses type hints. They do not impact anything at runtime like I once thought, but they are used by IDE's to help the developer. For instance, when a function is created with type hints and it is used elsewhere in the same file, PyCharm creates this handy popup for each argument with its associated type. I'm unsure how other IDEs and linters utilize type hints, but this can still be useful to have.

Example:
image

For more info on typing in Python https://docs.python.org/3/library/typing.html#

from geocat.

erogluorhan avatar erogluorhan commented on June 27, 2024

This is a good catch! At this point, I'd suggest making a research to see if there is any practical ways of actually conducting runtime checks for argument types. If there is not, then forcing type hints may be discussed again, taking its limited help into account. Also, I think @anissa111 had some thoughts about type hints would change with a future Python version?

from geocat.

hCraker avatar hCraker commented on June 27, 2024

In our team meeting yesterday, we decided to not require type hints, and our stance on them is neutral. Because types are already listed in the required doc strings for each function, the addition of type hints would not add any information to our software. In addition, type hints do not have any influence at runtime and cannot throw errors when incorrect types are passed in. However, we recognize that they can be useful for developers using certain IDE's and type checkers. It is up to individual contributor's discretion whether or not to include type hints.

from geocat.

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.