Skip to content

Conversation

@roberto-arista
Copy link
Contributor

Hey!

I've recently noticed a couple of issues with hints:

  • some **kwargs wrongly hinted as dict[str, something]
  • missing return type hints (pyright does infer most of them but mypy instead defaults to Any, so better specify them)

I've also left a few comments on the code on hints/validations that I'd like an input from you. I'll try to expose them as discussions here in the PR thread.

I propose to open a separate PR to complete the ruff integration. They can probably go in parallel.

self._addInstruction("writingDirection", direction)

def openTypeFeatures(self, *args: bool | None, **features: bool) -> dict[str, bool]:
def openTypeFeatures(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am sure we discussed this already, but why do we need args here? From the examples is not evident to me...

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps it's time to remove it. It's for bw compat of an earlier call signature. See the implementation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I assume you refer to openTypeFeatures(None). @typemytype what do you think?

listOpenTypeFeatures.__doc__ = FormattedString.listOpenTypeFeatures.__doc__

def fontVariations(self, *args: None, **axes: float | bool):
def fontVariations(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • there was a specific reason to also have a bool on the **axes?
  • is args needed?

Copy link
Collaborator

Choose a reason for hiding this comment

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

bool: I think it's for the resetVariations case. See the implementation. It's an odd call signature.
args here is also for bw compatibility. Perhaps time to remove.

Perhaps this should be rewritten like this:

    def fontVariations(self, *, resetVariations: bool = False, **axes: float) -> dict[str, float]:
        ...

I bet the current version predates the "*" feature that says "only keyword args follow". That's the main point: we want to ensure resetVariations is passed as a keyword argument.

methods affected:
- `lineCap`
- `underline`
- `strikethrough`
- `writingDirection`
- `text`
- `textBox`
- `textBoxBaselines`
@roberto-arista
Copy link
Contributor Author

morning! @typemytype could you have a look at the PR? thanks : )

@justvanrossum
Copy link
Collaborator

I think you should first make sure that the CI doesn't fail. There's currently a mypy error.

@roberto-arista
Copy link
Contributor Author

Sure, I'll take care of it. I am curious to know what @typemytype thinks of the open discussions : )

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.

2 participants