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

Type hints aren't recursive #119

Open
alexiswl opened this issue Feb 20, 2024 · 3 comments
Open

Type hints aren't recursive #119

alexiswl opened this issue Feb 20, 2024 · 3 comments
Assignees
Labels
help wanted Extra attention is needed
Milestone

Comments

@alexiswl
Copy link
Member

Given a function such as the one below

def get_project_data_obj_by_id(
    project_id: str,
    data_id: str
) -> ProjectData:
    """
    Given a project_id and a data_id, return the data object

    :param project_id:
    :param data_id:

    :return:
    """

    # Get the configuration
    configuration = get_icav2_configuration()

    # Enter a context with an instance of the API client
    with ApiClient(configuration) as api_client:
        # Create an instance of the API class
        api_instance = ProjectDataApi(api_client)

    # example passing only required values which don't have defaults set
    try:
        # Retrieve the list of project data.
        data_obj: ProjectData = api_instance.get_project_data(
            project_id=project_id,
            data_id=data_id
        )
    except ApiException as e:
        logger.error("Exception when calling ProjectDataApi->get_project_data_list: %s\n" % e)
        raise ApiException

    return data_obj

I can call this function to retrieve a project data object.

my_project_data_obj = get_project_data_obj_by_id("my_project_id", "my_data_id")

PyCharm IDE then gives me the following attributes as expected if I was to write my_project_data_obj.

image

However, despite the attribute data being of type Data - see https://umccr-illumina.github.io/libica/openapi/v2/docs/ProjectData/ or screenshot below

image

When I try and perform an action on the attribute, I don't get any helpful suggests, even though libica should know it's of type Data.

image

@alexiswl alexiswl added the help wanted Extra attention is needed label Feb 20, 2024
@victorskl
Copy link
Member

This might be relating to late binding... I will see to it

@victorskl victorskl added this to the 2.5.0 milestone Jun 18, 2024
@alexiswl
Copy link
Member Author

Also running into issues where PyCharm won't highlight errors when I access attributes that don't exist

i.e

If I try and use project_pipeline_obj.status I have no error, but on runtime this will result in an error since I should have used project_pipeline_obj.pipeline.status instead

@victorskl
Copy link
Member

I check this as well. Yup, I can reproduce.

As discussed, this entails upgrade to Python generator which will break backward compatibility, probably.

I have created milestone 3.0 as forward planning upgrade.

@victorskl victorskl modified the milestones: 2.5.0, 3.0 Jul 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants