Skip to content

Conversation

@tdstein
Copy link
Collaborator

@tdstein tdstein commented Dec 12, 2024

No description provided.

@github-actions
Copy link

github-actions bot commented Dec 12, 2024

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
1949 1790 92% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
src/posit/connect/client.py 99% 🟢
src/posit/connect/content.py 96% 🟢
src/posit/connect/packages.py 0% 🟢
src/posit/connect/resources.py 92% 🟢
TOTAL 72% 🟢

updated for commit: ebc70d4 by action🐍

@tdstein tdstein force-pushed the tdstein/packages-with-protocols branch from fc57890 to 84fdb8d Compare December 12, 2024 18:46
@tdstein tdstein marked this pull request as ready for review December 12, 2024 18:49
@tdstein tdstein requested review from schloerke and toph-allen and removed request for schloerke December 12, 2024 18:53

app_id: Required[str]
"""The numerical identifier of the application this package is associated with"""
class _Packages(Sized, Protocol):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to suffix the class names with P to help visually declare that it's a protocol class?

Suggested change
class _Packages(Sized, Protocol):
class _PackagesP(Sized, Protocol):

(Much easier to perform with "rename symbol")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually, I think we should make these public types. External users may want to use them for type hinting.

For example...

from posit.connect import Client, Packages

client = Client()
packages: Packages = client.packages

version: Required[str]
hash: Required[Optional[str]]
@overload
def __getitem__(self, index: slice) -> _ContentPackage: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def __getitem__(self, index: slice) -> _ContentPackage: ...
def __getitem__(self, index: slice) -> list[_ContentPackage]: ...

Comment on lines +12 to +16
@overload
def __getitem__(self, index: SupportsIndex) -> _ContentPackage: ...

class ContentPackage(Active):
class _Package(TypedDict):
language: Required[str]
name: Required[str]
version: Required[str]
hash: Required[Optional[str]]
@overload
def __getitem__(self, index: slice) -> _ContentPackage: ...
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to put this into a generic helper class?

class _GetItem(Sized, Generic[T], Protocol):
    @overload
    def __getitem__(self, index: SupportsIndex) -> T: ...

    @overload
    def __getitem__(self, index: slice) -> list[T]: ...

@schloerke schloerke mentioned this pull request Dec 12, 2024
Co-authored-by: Barret Schloerke <[email protected]>
@tdstein tdstein merged commit 733135c into tdstein/jobs-with-protocols Dec 13, 2024
35 checks passed
@tdstein tdstein deleted the tdstein/packages-with-protocols branch December 13, 2024 16:34
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.

3 participants