Skip to content

Add py.typed type hint marker#14

Closed
bact wants to merge 3 commits intospdx:mainfrom
bact:add-type-hint-marker
Closed

Add py.typed type hint marker#14
bact wants to merge 3 commits intospdx:mainfrom
bact:add-type-hint-marker

Conversation

@bact
Copy link
Collaborator

@bact bact commented Jan 22, 2026

To indicates that this package supports typing.

This will silent linter warning of "import-untyped" when importing spdx_python_model.

More about py.typed marker
https://peps.python.org/pep-0561/

To indicates that this package supports typing.

This will silent linter warning of "import-untyped" when importing spdx_python_model.

More about py.typed
https://peps.python.org/pep-0561/

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@bact bact requested review from JPEWdev and maxhbr January 22, 2026 14:24
@bact bact added the enhancement New feature or request label Jan 22, 2026
bact added 2 commits January 31, 2026 23:28
Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
Not a standard classifier.

Signed-off-by: Arthit Suriyawongkul <arthit@gmail.com>
@benjarobin
Copy link
Contributor

benjarobin commented Feb 24, 2026

I do not fully agree with this change. There is a lot of information missing.
For example the software_Package class (this is the case for any element) has the following properties: software_downloadLocation, software_packageUrl, software_packageVersion, ...
But all static analysis tools cannot see these properties.
This is going to break all the tools that depend on this library and which are using mypy. Please do not merge that (now)!

The proper solution would be to provide a generated .pyi !

@bact
Copy link
Collaborator Author

bact commented Feb 24, 2026

@benjarobin for pyi stub, see JPEWdev/shacl2code#74

@bact
Copy link
Collaborator Author

bact commented Feb 24, 2026

We need BOTH the .pyi stub and the py.typed marker btw.

According to Python typing guide
https://typing.python.org/en/latest/guides/libraries.html

As specified in PEP 561, tools will not treat your package as providing type information unless it includes a special py.typed marker file.

So we need these changes:

  1. generate pyi stub Generate Python type stub - allowing more code completion in IDE JPEWdev/shacl2code#74
  2. release new schacl2code version
  3. update schacl2code version in spdx-3-model
  4. copy pyi stub to module path Copy stubs to bindings path after generation at build #18
  5. add py.typed marker Add py.typed type hint marker #14 (this PR)
  6. release new spdx-python-model version

In that order (or maybe not in that exact order; but 2 must be after 1, and 3, 4, 5 must be after 2 and before 6).

@benjarobin
Copy link
Contributor

benjarobin commented Feb 25, 2026

We need BOTH the .pyi stub and the py.typed marker btw.

Oh, I see, sorry about that. I was persuaded this was not necessary if the package provided stub files.

generate pyi stub Generate Python type stub - allowing more code completion in IDE JPEWdev/shacl2code#74

Thank you so much for working on that part ! I did not see it. I would have saved a lot of time when developing sbom-cve-check. Again thank you!

But maybe you should "merge" this pull request with #18
I think you could close this one and add a commit to #18 that adds the py.typed file.

@bact
Copy link
Collaborator Author

bact commented Feb 25, 2026

But maybe you should "merge" this pull request with #18 I think you could close this one and add a commit to #18 that adds the py.typed file.

True. Better that way, so relevant changes are kept together. Thank you for the suggestion.

@bact bact closed this Feb 25, 2026
@bact bact deleted the add-type-hint-marker branch February 25, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants