Skip to content

Conversation

@johnslavik
Copy link
Member

@johnslavik johnslavik commented Jan 8, 2026

I've checked the docs and they're correct; only the docstring was wrong.
I think we can use this pseudocode type annotation here? Open for a better idea.

@johnslavik johnslavik changed the title Fix inspect parameter docstring Fix inspect.Parameter docstring on the kind attribute Jan 8, 2026
@johnslavik johnslavik requested a review from picnixz January 18, 2026 02:31
@picnixz
Copy link
Member

picnixz commented Jan 18, 2026

Is it just a C/C from the online docs?

@johnslavik
Copy link
Member Author

Is it just a C/C from the online docs?

No, not at all

@picnixz
Copy link
Member

picnixz commented Jan 18, 2026

Then I am a bit confused about the change. When I asked C/C from the online docs, I wanted to know whether the online docs indicated the description field and that 'kind' was an enumeration.

@johnslavik
Copy link
Member Author

johnslavik commented Jan 18, 2026

The online documentation does not specifiy whether kind is a string or int or enum, if that's what your asking (see https://docs.python.org/3/library/inspect.html#inspect.Parameter.kind). However, https://docs.python.org/3/library/inspect.html#inspect.Parameter.kind.description does imply that Parameter.kind is an enum.

Then I am a bit confused about the change.

What makes it confusing? What can I do?

@picnixz
Copy link
Member

picnixz commented Jan 18, 2026

I am confused by "the docstring was wrong". AFAICT, it is not wrong. If you indicate that kind is an enum in te docstring it should be reflected in the online docs as well.

parameter has no annotation, this attribute is set to
`Parameter.empty`.
* kind : str
* kind : int (enum)
Copy link
Member Author

Choose a reason for hiding this comment

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

@picnixz, kind : str is wrong. It is never a string.

Copy link
Member

Choose a reason for hiding this comment

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

Ah! I missed this change! my bad!

Copy link
Member

Choose a reason for hiding this comment

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

Ah! I missed this change! my bad!

@johnslavik
Copy link
Member Author

johnslavik commented Jan 18, 2026

If you indicate that kind is an enum in te docstring it should be reflected in the online docs as well.

It is not explicitly reflected. Online docs don't annotate types as this docstring does.
From the .description online documentation I linked to, one can imply that inspect.Parameter.kind is an enum.

@johnslavik
Copy link
Member Author

johnslavik commented Jan 18, 2026

What can I do to address the concerns about the PR?

Copy link
Member

@picnixz picnixz left a comment

Choose a reason for hiding this comment

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

Ok I actually missed the fact that it was documented as a string...

As a follow-up, I would suggest that:

  • You explicitly mention that it is an enumeration in the docs.
  • You explicitly say that it has a description property.

We could document the enumeration as well as a class right? (or is it an implementation detail?)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants