typeshed-internal / stub_uploader

Scripts and actions to auto-upload typeshed stubs to PyPI
Apache License 2.0
21 stars 16 forks source link

Allow marking stubs as partial #94

Closed Avasam closed 1 year ago

Avasam commented 1 year ago

Closes #93

I'm sure this can be improved. Also please review and test carefully (I'm still running integration tests, but they're taking forever).

The basic idea is to infer a stub package being partial from finding ignore_missing_stub = true in the metadata. If we decide to add a specific "partial" entry in the metadata, the logic will stay the same, only the property's inner code will change. Edit: went for a separate metadata key.

Alternatively typeshed could add the partial\n py.typed marker itself (assuming it can use packages instead of single files for single-file source w/o problem with stubtest)

srittau commented 1 year ago

In that case it would probably make sense to rename ignore_missing_stub to partial or partial_stub and clearly document what it does on the typeshed side. I'm a bit uncomfortable about adding the partial marker just by looking at some field named ignore_missing_stub.

Avasam commented 1 year ago

In that case it would probably make sense to rename ignore_missing_stub to partial or partial_stub and clearly document what it does on the typeshed side. I'm a bit uncomfortable about adding the partial marker just by looking at some field named ignore_missing_stub.

I personally wouldn't rename [tool.stubtest].ignore_missing_stub (at least not due to this feature).

I infer from it, because having stubtest ignore missing stubs usually means that, well, there's missing stubs! (and so, the stub package should probably be marked as partial, so that we don't hide public API that is not yet typed). I do recognize this may not always be the case in the future (as we both alluded to, ignore_missing_stub and partial are semantically different), so if you'd prefer going immediately for a different setting, let's do that 😃 (and the required changes in typeshed).

I see two ways of doing it (more suggestions welcome). Whichever solution should be well documented in typeshed.

  1. Let typeshed add py.typed markers itself. And a test to ensure it contains partial\n. stub_uploader then only needs to include them in its filters.
  2. Add a new metadata entry partial or partial_stub, keep this PR mostly as-is.

Now for example use cases where partial_stub = true and ignore_missing_stub = false:

partial_stub = false and ignore_missing_stub = true:

srittau commented 1 year ago

I'd prefer to split those features, i.e. have a separate partial_stub key in the METADATA.toml file for the use cases you outlined and to avoid "hidden" side effects.