github / github/copilot-sdk

[v2][Python] Make generated implementation modules private

Offen
#2,048 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
bug sdk-v2
Vorherrschende Sprache
Java
Sterne
10.5k
Forks
1.5k
Ø Merge
1 T. 11 Std.
Gemergte PRs (30 T.)
127

Beschreibung

https://github.com/github/copilot-sdk/blob/main/python/copilot/generated/__init__.py Makes it clear that the `copilot.generated` subpackage is not meant to be public:

https://github.com/github/copilot-sdk/blob/cd2b10b07e8f393b09379dfda6b30f658b2963d2/python/copilot/generated/__init__.py#L3

But the subpackage doesn't start with an underscore to signify it's an implementation detail: `copilot._generated`.

As well, https://github.com/github/copilot-sdk/blob/main/python/copilot/rpc.py and https://github.com/github/copilot-sdk/blob/main/python/copilot/session_events.py which are meant to act as the public API potentially over-expose things. While `copilot.rpc` does export something explicitly:

https://github.com/github/copilot-sdk/blob/cd2b10b07e8f393b09379dfda6b30f658b2963d2/python/copilot/rpc.py#L10-L11

... both files **also** do an `import *` followed by an import of `__all__` from the generated code which lists everything contained in the generated code. E.g.:

https://github.com/github/copilot-sdk/blob/cd2b10b07e8f393b09379dfda6b30f658b2963d2/python/copilot/session_events.py#L9-L10

exposes 330 symbols in the module:

https://github.com/github/copilot-sdk/blob/cd2b10b07e8f393b09379dfda6b30f658b2963d2/python/copilot/generated/session_events.py#L9883-L10215

I'm not sure if all 330 symbols are meant to be exposed, but at least `copilot.generated` should be made private by renaming it to `copilot._generated`. If all of those symbols are meant to be exposed then that one-liner in `copilot.rpc` might as well be removed. If they are not meant to be exposed then the `import __all__` and `import *` should go and you can explicitly set `__all__` in the exporting modules.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start with python/copilot/generated/__init__.py, python/copilot/rpc.py, python/copilot/session_events.py, and the generated rpc.py and session_events.py modules. Trace which generated symbols are intended to be public before changing the package name or export lists. Done means implementation modules are private and the public modules expose only the intended API without accidental generated symbols.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api
Issue-Typ
Refactoring
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
55/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.