Skip to content

Expand type annotations and add classes for path item handling#412

Open
pappnu wants to merge 22 commits into
loonghao:mainfrom
pappnu:type-annotation
Open

Expand type annotations and add classes for path item handling#412
pappnu wants to merge 22 commits into
loonghao:mainfrom
pappnu:type-annotation

Conversation

@pappnu
Copy link
Copy Markdown

@pappnu pappnu commented Aug 12, 2025

This PR adds extensive type annotations, various missing properties, classes for interacting with path items and tries to lessen some of the repetition within the code. The type annotations don't cover everything, especially things that would have required creating new wrapper classes. The annotations are mostly based on Photoshop Scripting Reference and Photoshop JavaScript Scripting Reference 2020.

Breaking Changes

  • Python requirement is raised to 3.10 because of the used syntax.
  • Removes Application.compareWithNumbers, Application.system and Session.echo functions as they simply wrapped basic Python actions without adding any extra functionality to them, so I assumed they aren't really necessary.
  • getByName now returns None instead of throwing, as I find that easier to work with in a strictly typed codebase.

Testing

I added some tests of my own and ran some of the existing tests, though many of them didn't pass even when using the version from main branch. I have also used this extensively with Proxyshop, which uses especially the basic layer modification and action manager parts of the API. There's still many untested properties and functions, so bugs are quite likely.

This might also help with #405.

Please let me know what further changes would be required to get this merged.

| PhotoshopSaveOptions
| TargaSaveOptions
| TiffSaveOptions
| None = None,
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

| PNGSaveOptions
| PhotoshopSaveOptions
| TargaSaveOptions
| TiffSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

| PDFSaveOptions
| PNGSaveOptions
| PhotoshopSaveOptions
| TargaSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

| JPEGSaveOptions
| PDFSaveOptions
| PNGSaveOptions
| PhotoshopSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

| GIFSaveOptions
| JPEGSaveOptions
| PDFSaveOptions
| PNGSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

| EPSSaveOptions
| GIFSaveOptions
| JPEGSaveOptions
| PDFSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

options: BMPSaveOptions
| EPSSaveOptions
| GIFSaveOptions
| JPEGSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

file_path: str,
options: BMPSaveOptions
| EPSSaveOptions
| GIFSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

self,
file_path: str,
options: BMPSaveOptions
| EPSSaveOptions
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line break before binary operator

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.

1 participant