Skip to content

Commit

Permalink
fix: __ContentOnlyElement.text property is always str
Browse files Browse the repository at this point in the history
It is empty string even when there is no text content for __ContentOnlyElement. Partially addresses #46.
  • Loading branch information
abelcheung committed Apr 12, 2024
1 parent 502e957 commit 0e413f5
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions lxml-stubs/etree/_element.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,9 @@ class _Attrib:
class __ContentOnlyElement(_Element):
#
# Useful properties
# .text and .tag are overridden in each concrete class below
#
@property
def text(self) -> str | None: ...
@text.setter
def text( # pyright: ignore[reportIncompatibleMethodOverride]
self, value: _t._AnyStr | None
) -> None: ...
@property
def attrib(self) -> Mapping[_t.Unused, _t.Unused]: ... # type: ignore[override]
def get(self, key: _t.Unused, default: _t.Unused = None) -> None: ... # type: ignore[override]
def set(self, key: Never, value: Never) -> Never: ... # type: ignore[override]
Expand All @@ -463,11 +458,23 @@ class __ContentOnlyElement(_Element):
class _Comment(__ContentOnlyElement):
@property # type: ignore[misc]
def tag(self) -> _t._ElemFactory[_Comment]: ... # type: ignore[override]
@property # type: ignore[override]
def text(self) -> str: ...
@text.setter
def text( # pyright: ignore[reportIncompatibleMethodOverride]
self, value: _t._AnyStr | None
) -> None: ...

# signature of .get() for _PI and _Element are the same
class _ProcessingInstruction(__ContentOnlyElement):
@property # type: ignore[misc]
def tag(self) -> _t._ElemFactory[_ProcessingInstruction]: ... # type: ignore[override]
@property # type: ignore[override]
def text(self) -> str: ...
@text.setter
def text( # pyright: ignore[reportIncompatibleMethodOverride]
self, value: _t._AnyStr | None
) -> None: ...
@property
def target(self) -> str: ...
@target.setter
Expand Down

0 comments on commit 0e413f5

Please sign in to comment.