Skip to content

Comments

Upgrade upstream#1

Open
anayden wants to merge 5 commits intomascotbot:mainfrom
unkeyed:main
Open

Upgrade upstream#1
anayden wants to merge 5 commits intomascotbot:mainfrom
unkeyed:main

Conversation

@anayden
Copy link
Collaborator

@anayden anayden commented Aug 5, 2025

No description provided.

@anayden anayden requested a review from Copilot August 5, 2025 19:17
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades the Unkey Python SDK with several modernizations and API enhancements. The changes primarily focus on replacing deprecated libraries, improving type safety, and adding new functionality to align with upstream API changes.

  • Replaces deprecated typing-inspect with native type checking using Union detection
  • Replaces NewType with TypeAlias for better type hinting
  • Adds new features like analytics module, additional request parameters, and enhanced error handling

Reviewed Changes

Copilot reviewed 121 out of 126 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/unkey_py/utils/serializers.py Removes deprecated typing-inspect and adds custom is_union helper function
src/unkey_py/types/basemodel.py Replaces NewType with TypeAlias for better type annotations
src/unkey_py/utils/datetimes.py Adds new datetime parsing utility with Python version compatibility
src/unkey_py/utils/enums.py Adds Python 3.11+ compatibility for enum boundary parameter
src/unkey_py/sdk.py Adds analytics module and improves client lifecycle management
src/unkey_py/models/*.py Updates various models to use Nullable[Any] for metadata fields and fixes serialization
Comments suppressed due to low confidence (1)

src/unkey_py/utils/forms.py:118

  • The removal of the field_name variable and its associated logic could cause issues in multipart form handling. The original code used field_name to determine the field name for file uploads, and removing this logic might break file upload functionality.
            content = None

return ""

return json.dumps(d[next(iter(d))], separators=(",", ":"), sort_keys=True)
return json.dumps(d[next(iter(d))], separators=(",", ":"))
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The removal of sort_keys=True parameter changes the serialization behavior. This could cause issues if the serialized JSON is used for hashing, comparison, or other operations that depend on consistent key ordering.

Suggested change
return json.dumps(d[next(iter(d))], separators=(",", ":"))
return json.dumps(d[next(iter(d))], separators=(",", ":"), sort_keys=True)

Copilot uses AI. Check for mistakes.
m = {}

for n, f in self.model_fields.items():
for n, f in type(self).model_fields.items():
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The change from self.model_fields to type(self).model_fields could cause issues if the model has dynamic fields or if the instance has been modified after creation. The original self.model_fields provided access to instance-specific field information.

Suggested change
for n, f in type(self).model_fields.items():
for n, f in self.model_fields.items():

Copilot uses AI. Check for mistakes.
OptionalNullable[int],
FieldMetadata(query=QueryParamMetadata(style="form", explode=True)),
] = UNSET
] = 1746664158001
Copy link

Copilot AI Aug 5, 2025

Choose a reason for hiding this comment

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

The hardcoded timestamp value 1746664158001 appears to be a magic number. This should be replaced with a named constant or calculated value to improve code maintainability and clarity.

Suggested change
] = 1746664158001
] = DEFAULT_END_TIMESTAMP

Copilot uses AI. Check for mistakes.
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