Skip to content

Conversation

@Syzygy106
Copy link

What I did

fixes:
Fixes #2698

Migrated type hints to Python 3.10+ syntax:

  1. Replaced Optional[T] with T | None
  2. Replaced Union[A, B, ...] with A | B | ...
  3. Updated minimum Python version to 3.10
  4. Fixed type introspection to support new union syntax

How I did it

  1. Type hint migration: Replaced Optional and Union with | syntax throughout the codebase
  2. Type introspection: Updated converters.py to handle both old (Union/Optional) and new (|) syntax using get_origin() and get_args()
  3. Configuration: Updated pyproject.toml and setup.py to require Python 3.10+
  4. Bug fix: Added ignore_cleanup_errors=True to TemporaryDirectory calls

How to verify it

Run the test suite:

pytest

To be clear, there were already failing tests in the baseline. My changes didn't introduce any regressions (and actually fixed 1 test).

Checklist

  • All changes are completed
  • Change is covered in tests
  • Documentation is complete

@Syzygy106
Copy link
Author

As I see, there still a lot of issues, so I'll complete refactor

@Syzygy106
Copy link
Author

@fubuloubu, could you verify PR?

Copy link
Member

@fubuloubu fubuloubu left a comment

Choose a reason for hiding this comment

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

This looks fantastic! Thanks for taking the time and submit this. Left a few small comments

Returns:
Optional[:class:`~ape.api.networks.ProxyInfoAPI`]: Returns ``None`` if the contract
ProxyInfoAPI | None: Returns ``None`` if the contract
Copy link
Member

Choose a reason for hiding this comment

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

Does this still show up the same if we avoid the class syntax?

"ContractMethodQuery",
]
QueryType = (
"BlockQuery | BlockTransactionQuery | AccountTransactionQuery | ContractCreationQuery | ContractEventQuery | ContractMethodQuery"
Copy link
Member

Choose a reason for hiding this comment

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

You probably are able to split this up to make it a little nicer

Suggested change
"BlockQuery | BlockTransactionQuery | AccountTransactionQuery | ContractCreationQuery | ContractEventQuery | ContractMethodQuery"
"BlockQuery"
" | BlockTransactionQuery"
" | AccountTransactionQuery"
" | ContractCreationQuery"
" | ContractEventQuery"
" | ContractMethodQuery"

Comment on lines +752 to 753
extra_addresses (list | None): Additional contract addresses containing the same event type. Defaults to
Additional contract addresses containing the same event type. Defaults to
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
extra_addresses (list | None): Additional contract addresses containing the same event type. Defaults to
Additional contract addresses containing the same event type. Defaults to
extra_addresses (list | None): Additional contract addresses containing the same event type. Defaults to

Comment on lines +456 to +457
from typing import get_args, get_origin, Union
from types import UnionType
Copy link
Member

Choose a reason for hiding this comment

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

I think we can put these imports at the top no problem

def convert_method_kwargs(self, kwargs) -> dict:
fields = TransactionAPI.__pydantic_fields__

def get_real_type(type_):
Copy link
Member

Choose a reason for hiding this comment

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

To what degree were you able to test this working with the new changes?

@Syzygy106
Copy link
Author

This looks fantastic! Thanks for taking the time and submit this. Left a few small comments

Wait. Since checking failing tests, I feel we need to accomplish a refactor first #2724
. So let's stop current PR. Don't merge it into main.

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.

Deprecate Python 3.9

2 participants