Skip to content

Commit

Permalink
Implement bool() for string paths
Browse files Browse the repository at this point in the history
  • Loading branch information
AA-Turner committed Aug 23, 2023
1 parent 494de73 commit 511e407
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sphinx/util/_pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ def __add__(self, other):
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return self.__str__() + other

def __bool__(self):
if not self.__str__():
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return False
return True

def __contains__(self, item):
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return item in self.__str__()
Expand Down Expand Up @@ -79,6 +85,12 @@ def __add__(self, other):
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return self.__str__() + other

def __bool__(self):
if not self.__str__():
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return False
return True

def __contains__(self, item):
warnings.warn(_MSG, RemovedInSphinx80Warning, stacklevel=2)
return item in self.__str__()
Expand Down

0 comments on commit 511e407

Please sign in to comment.