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 a *.pyi file for auto-completion & hints. #7009

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Minokori
Copy link

Description

To enable auto-completion and hints in code editors such as VScode, create a *.pyi file. This feature is compatible with python 3.9 and later versions.

Where has this been tested?

  • Platform(s): Windows Desktop ...
  • Python version(s): 3.9.10 ...
  • Unreal Engine version(s): ...

Possible Drawbacks

It might be incompatible with python 3.8 or earlier versions.

To enable auto-completion and hints in code editors such as VScode, create a `*.pyi` file. This feature is compatible with `python 3.9` and later versions.
@Minokori Minokori requested a review from a team as a code owner December 16, 2023 08:23
Copy link

update-docs bot commented Dec 16, 2023

Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would update our CHANGELOG.md based on your changes.

@Daraan
Copy link
Contributor

Daraan commented Feb 10, 2024

So far it works with Python 3.7 without greater issues, but only looked into some small aspects. (Thanks a lot btw.!)

"""One of the most important groups of actors in CARLA. These include any type of vehicle from cars to trucks, motorbikes, vans, bycicles and also official vehicles such as police cars. A wide set of these actors is provided in `carla.BlueprintLibrary` to facilitate differente requirements. Vehicles can be either manually controlled or set to an autopilot mode that will be conducted client-side by the `traffic manager`."""

# region Instance Variables
def bounding_box() -> BoundingBox:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the bounding_box is lacking a @property here.

def get_actors(self, actor_ids: list = None) -> ActorList:
"""Retrieves a list of `carla.Actor` elements, either using a list of IDs provided or just listing everyone on stage. If an ID does not correspond with any actor, it will be excluded from the list returned, meaning that both the list of IDs and the list of actors may have different lengths."""

def get_blueprint_library(self) -> list[BlueprintLibrary]:
Copy link
Contributor

@Daraan Daraan Feb 13, 2024

Choose a reason for hiding this comment

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

get_blueprint_library returns just a BlueprintLibrary`object and not a list.
Wording is a bit ambiguous in in the original documentation.

https://carla.readthedocs.io/en/latest/python_api/#carla.World

"""Returns the blueprint stored in `pos` position inside the data structure containing them.
"""

def __iter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can be improved by using:

    def __iter__(self) -> Iterator[ActorBlueprint]:

# region Dunder Methods
def __getitem__(self, pos: int): ...

def __iter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this one be improved too?

"""Returns the actor corresponding to pos position in the list."""
...

def __iter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

-> List[Actor]

# endregion

# region Dunder Methods
def __iter__(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

-> List[ActorAttribute]:

Copy link
Contributor

@Daraan Daraan left a comment

Choose a reason for hiding this comment

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

Update included in my latest pull request

...

@property
def parent() -> ["Actor"]:
Copy link
Contributor

Choose a reason for hiding this comment

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

[Type] is not proper. Should be changed to Optional["Actor"] or Union[None, "Actor"]

@Daraan
Copy link
Contributor

Daraan commented Feb 29, 2024

Completed the last todos, and added further fixes as well as a changelog to my pull request on @Minokori's branch.

In my opinion afterwards its ready to merge

@Daraan
Copy link
Contributor

Daraan commented Mar 13, 2024

TODO: Undocumented and wrongly documented; see #7236. Official docs should likely be updated fist. Done

Some included in latest pull request.

# endregion

# region Methods
def __init__(self, name: str, xodr_content: str) -> list[Transform]:
Copy link
Contributor

Choose a reason for hiding this comment

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

__init__ should not return, and this is additionally wrong imo.

Fixes for all __init__s included in the latest pushes to my PR

@Daraan
Copy link
Contributor

Daraan commented Apr 16, 2024

Need to look out for #7439 de depending on the progress the Sensor needs changing later on. Latest push sets it up to date.

@Blyron
Copy link
Contributor

Blyron commented Apr 17, 2024

Hey @Minokori All PRs must be against dev, could you correct this please?

@Blyron
Copy link
Contributor

Blyron commented May 7, 2024

If this PR does not go against dev we will need to close it and reject it

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.

None yet

3 participants