Type annotations in cloudinit.distros.Distros#6938
Conversation
|
Please sign the CLA. Also, type annotations are only useful if they are used by mypy. |
|
i've signed the CLA. I'll proceed by adding the types and checking them with mypy through tox. |
|
Note: mypy is still running into errors, so this PR is still not ready to merge |
|
Update: I've successfully identified the issues and have finished the task. |
|
It looks like tests are still failing. |
|
I've run the formatting command: tox -e do_formatI'll start fixing the failing tests now. I've already looked through them, and they seem easy to fix. They should be ready shortly. |
|
I've identified the root cause of the failing tests and completed the fix. The main issue was that I was using a feature introduced in Python 3.10—the union operator ( I'm now waiting for the workflow to complete to verify that everything passes successfully. |
|
Everything's passing. It just needs a quick review now. |
| hostname_conf_fn = "/etc/hostname" | ||
| shadow_fn = "/etc/shadow" | ||
| shadow_extrausers_fn = "/var/lib/extrausers/shadow" | ||
| pip_package_name: str = "python3-pip" |
There was a problem hiding this comment.
Is this actually required? Generally mypy infers the type from the assignment.
There was a problem hiding this comment.
It's not exactly required for this variable because pip_package_name is always a string.
However, since some variables may be assigned to values of different types later on, i just chose to make it explicit for every one of them so that neither devs get confused nor mypy breaks somehow...
Whatever option you think is best, just let me know!
There was a problem hiding this comment.
Making it explicit for every one of them makes it more confusing - it makes me wonder why redundant type information would be necessary. The explicit type information is generally a requirement only when you are adding additional context (Option for example, tells mypy that this variable starts as NoneType and will later be assigned to another type).
Proposed Commit Message
Additional Context
Test Steps
Merge type