21

For example:

class FooBar:
    def __init__(self):
        self.a: int = None
        self.foo: str = None

Is this bad practice/go against PEP guidelines or is it fine?

you are viewing a single comment's thread
view the rest of the comments
[-] joyjoy@lemmy.zip 21 points 1 day ago

Implicit optional is deprecated. Explicitly use self.foo: int | None = None

[-] AstroLightz@lemmy.world 4 points 1 day ago

Thanks! Good to know.

this post was submitted on 16 Mar 2026
21 points (100.0% liked)

Python

7812 readers
13 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 2 years ago
MODERATORS