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

remove Decoration.name_expression again because Decoration.name is sufficient #44

Merged
merged 1 commit into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .changelog/_unreleased.yml

This file was deleted.

7 changes: 2 additions & 5 deletions docspec/src/docspec/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,14 @@ class Decoration:
Represents a decorator on a #Class or #Function.
"""

#: The name of the decorator (i.e. the text between the `@` and `(`).
#: The name of the decorator (i.e. the text between the `@` and `(`). In languages that support it,
#: this may be a piece of code.
name: t.Optional[str]

#: Decorator arguments as plain code (including the leading and trailing parentheses). This is
#: `None` when the decorator does not have call arguments.
args: t.Optional[str] = None

#: This field should be used instead of #name if the decorator is not just a simple name but
#: a complex expression.
name_expression: t.Optional[str] = None

#: The location of the decoration in the source code.
location: t.Optional[Location] = None

Expand Down
16 changes: 4 additions & 12 deletions docspec/src/specification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,24 +136,16 @@ Decoration:
docs: Represents a decoration that can be applied to a function or class.
fields:
name:
type: Optional[str]
docs: The name of the decorator used in this decoration. This may be `null` if the decorator
can not be represented simply by a name, e.g. in Python 3.9 where decorators can be full
fledged expressions. In that case the `name_expression` field is used instead.
type: str
docs: The name of the decorator used in this decoration. This may be a piece of code in languages
that support complex decoration syntax. (e.g. in Python, `@(decorator_factory().dec)(a, b, c)` should
be represented as `"(decorator_factory().dec)"` for the `name` and `["a", "b", "c"]` for the `args`).
args:
type: Optional[List[str]]
required: false
docs: A list of the raw source code for each argument of the decorator. If this is not set,
that means the decorator is not called. If the list is empty, the decorator is called without
arguments.
name_expression:
type: Optional[List[str]]
required: false
docs: The raw code string that represents the decorator that is used for this expression. This
is used if the decorator can not be represented by just a `name`. The `args` may still be used
if the expression gets called (e.g. in the case of `@(decorator_factory().dec)(a, b, c)`, the
`name_expression` should be `"(decorator_factory().dec)"` whereas the `args` should be
`["a", "b", "c"]`.
location:
type: Optional[List[str]]
required: false
Expand Down