-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
base: master
Are you sure you want to change the base?
Conversation
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.
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. |
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: |
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> List[ActorAttribute]:
There was a problem hiding this 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"]: |
There was a problem hiding this comment.
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"]
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 |
Some included in latest pull request. |
# endregion | ||
|
||
# region Methods | ||
def __init__(self, name: str, xodr_content: str) -> list[Transform]: |
There was a problem hiding this comment.
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
Need to look out for #7439 de depending on the progress the Sensor needs changing later on. Latest push sets it up to date. |
Hey @Minokori All PRs must be against dev, could you correct this please? |
If this PR does not go against dev we will need to close it and reject it |
Description
To enable auto-completion and hints in code editors such as VScode, create a
*.pyi
file. This feature is compatible withpython 3.9
and later versions.Where has this been tested?
Possible Drawbacks
It might be incompatible with
python 3.8
or earlier versions.