Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more type hints #1642

Merged
merged 1 commit into from
Jan 14, 2023
Merged

Add more type hints #1642

merged 1 commit into from
Jan 14, 2023

Conversation

outa
Copy link
Contributor

@outa outa commented Nov 25, 2022

Add some more type hints now that #1602 is merged.

cc: #1608

Checklist

  • I have read the contributing doc.
  • I have included a link to the relevant issue number.
  • I have checked to ensure there aren't other open pull requests
    for the same issue.
  • I have written new tests for these changes, as needed.

@@ -96,7 +96,7 @@ def _encrypt(self, text: str) -> bytes:

return self.encryption_method.encrypt(text)

def open(self, filename=None):
def open(self, filename: str | None = None) -> "Journal":
Copy link
Member

Choose a reason for hiding this comment

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

Can we use Optional[str] instead of str | None?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are equivalent right? So we could, but I have typed this consistently as str | None in #1614
Anything wrong with the new syntax?

@@ -17,7 +18,7 @@ def __str__(self) -> str:
JRNLV2 = "Jrnlv2Encryption"


def determine_encryption_method(config: str | bool) -> "BaseEncryption":
def determine_encryption_method(config: str | bool) -> Type["BaseEncryption"]:
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch here!

Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

Thanks for this! I think the only change is to use Optional instead of foo | None.

@outa outa force-pushed the more-type-hints branch from 73788ed to f30e1e9 Compare January 8, 2023 08:53
Copy link
Member

@wren wren left a comment

Choose a reason for hiding this comment

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

lgtm

Thank you!

@wren wren added the enhancement New feature or request label Jan 14, 2023
@wren wren merged commit a13726d into jrnl-org:develop Jan 14, 2023
@outa outa deleted the more-type-hints branch March 4, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants