Skip to content

Comments

fix: __package__ -> __spec__.parent#294

Open
henryiii wants to merge 2 commits intoabravalheri:mainfrom
henryiii:henryiii/fix/__package__
Open

fix: __package__ -> __spec__.parent#294
henryiii wants to merge 2 commits intoabravalheri:mainfrom
henryiii:henryiii/fix/__package__

Conversation

@henryiii
Copy link
Collaborator

@henryiii henryiii commented Feb 4, 2026

I was reworking the typing job a bit, mostly to try ty, and it noticed that we are using __package__, which is scheduled for removal in 3.15. I moved this over to the replacement. This includes the original restructuring to try out ty, which also removes the pin on Python. tomli has to be required unconditionally. And the typechecking tool is moved to the job, since you could be using a different tool (like ty).

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Comment on lines +68 to +70
assert __spec__ is not None
assert __spec__.parent is not None
return load(name, f"{__spec__.parent}.plugins")
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert __spec__ is not None
assert __spec__.parent is not None
return load(name, f"{__spec__.parent}.plugins")
return load(name, f"{PARENT}.plugins")

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, this change would be interesting.

deps = mypy
commands =
python -m mypy {posargs:--pretty --show-error-context src}
mypy src
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mypy src
mypy {posargs: src}

I could keep the extra formatting flags here too, I was checking to see if it worked hard coding them.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so this change basically undoes the proposed change in #131 (comment), right?

So does it mean that vscode/pycharm/iterm or GitHub Actions no longer have the problem with parsing the output?

Copy link
Owner

@abravalheri abravalheri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much Henry!

Comment on lines +68 to +70
assert __spec__ is not None
assert __spec__.parent is not None
return load(name, f"{__spec__.parent}.plugins")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, this change would be interesting.


def run(args: Sequence[str] = ()) -> int:
assert __spec__ is not None
assert __spec__.parent is not None
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly we assign a _PARENT constant here too?
Then the asserts can be done only once.


assert __spec__ is not None
assert __spec__.parent is not None
PARENT = __spec__.parent
Copy link
Owner

@abravalheri abravalheri Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe _PARENT to avoid people thinking it is a public member?

deps = mypy
commands =
python -m mypy {posargs:--pretty --show-error-context src}
mypy src
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK so this change basically undoes the proposed change in #131 (comment), right?

So does it mean that vscode/pycharm/iterm or GitHub Actions no longer have the problem with parsing the output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants