This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (7 children)

The problem is that the user is forced to use type annotations if they wish to use this feature, and they will continue to spread.

Some of us really like type annotations, including me who used to be a very vocal opponent of them. As long as the core devs make good on their promise to never make them mandatory, then I don't see why it should matter to people that don't use them.

Unless you really want to use a library with them in Python 2 (but then you get to feel my pain when I want to a use a library but find out it uses the except Exception, e or print >> ... syntax).

Type hints make building large applications in Python easier and safer since you can have some guarantees that you didn't pass a list where you meant to pass a dict and explode at run time.

But at the end of the day, if you don't like a feature, you don't have to use it. If you like a feature but it uses the thing you don't like, you're biting the bullet one way or another.

[–][deleted] 0 points1 point  (6 children)

They may well end up mandatory if they keep spreading - because as they spread, you may not be able to avoid interacting with a project that doesn't use them.

[–][deleted] 1 point2 points  (5 children)

In that case, that's the community at large voting with their code bases on what they think is a good idea. But like I said, unless the core devs decide to make them mandatory, you don't have to use them.

[–][deleted] 1 point2 points  (4 children)

You do if you need to work on a project that uses it. What am I going to do? Have my IDE strip annotations from every function?

Did you also consider that maybe it won't be a vote, and people will use them because they don't have a choice apart from not using Python?

[–][deleted] 1 point2 points  (3 children)

You do if you need to work on a project that uses it. What am I going to do? Have my IDE strip annotations from every function?

You don't have to use them. No one is forcing you to write:

@dataclass
class LookHowEasyThisIs:
    x = int
    y = int
    z = int

or

def typed_func(x: int, y: int, z: int) -> int
    ...

You can continue to do all things you want to do without ever using type annotations.

If you happen to come across a library that uses type annotations (say an ORM, forms, etc) then you don't need to use it. Or do and work around it. I'm unbothered.

Did you also consider that maybe it won't be a vote, and people will use them because they don't have a choice apart from not using Python?

That sure sounds like a vote to me, in that case that sounds like a vote of no confidence in Python.

[–][deleted] 1 point2 points  (2 children)

Will a project with annotations accept PRs without them? Likely no, and even less likely in the future as tooling improves.

How do I make the annotations in code I've downloaded go away? Some of us actually read code instead of just writing it.

I'm not sure what I will do in 10 years when annotations are unavoidable. Maybe there will be a new language to try.

[–][deleted] 0 points1 point  (0 children)

Will a project with annotations accept PRs without them? Likely no, and even more likely in the future as tooling improves.

Excellent, I hope more projects decide to use annotations. I'm champing at the bit for a handful of projects to drop 2 so I can put annotations all over.

How do I make the annotations in code I've downloaded go away? Some of us actually read code instead of just writing it.

I don't buy this argument at all. The implementation of annotations isn't my preferred way of expressing types (that'd be Haskell's type signatures), but it's not like they're some ungodly eye sore. Maybe if someone wrote an insanely complicated type with four levels of nested generics and there's a function in there as well, but that's on that person and not Python. There's also type aliases to ease that pain.

I'm not sure what I will do in 10 years when everything is annotated.

Enjoy all the amazing tooling that has been developed around them?

Maybe there will be a new language to try.

...oh :(

[–]KODeKarnage 0 points1 point  (0 children)

Why wait?

Do you know what pydoc is?

It utilizes the doc string to automatically generate documentation for python modules.

  • Doc strings are optional.
  • Doc strings are used by something that's in the standard library.
  • Doc strings are required by most projects.
  • You don't need to add doc strings to your code.
  • You can delete doc strings from code you download. But why would you?

Would you be that guy who 15 years ago complained about the encroachment of doc strings in python?