Skip to content

Commit

Permalink
Close #2070. Re-introduce part_of_speech argument to words() meth…
Browse files Browse the repository at this point in the history
…od (#2072)
  • Loading branch information
fcurella committed Aug 12, 2024
1 parent f03de2c commit ffa364b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 2 additions & 4 deletions faker/providers/lorem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def words(
self,
nb: int = 3,
ext_word_list: Optional[List[str]] = None,
part_of_speech: Optional[str] = None,
unique: bool = False,
) -> List[str]:
"""Generate a tuple of words.
Expand All @@ -89,10 +90,7 @@ def words(
:sample: nb=4, ext_word_list=['abc', 'def', 'ghi', 'jkl'], unique=True
"""

if ext_word_list is None:
word_list = self.get_words_list()
else:
word_list = ext_word_list
word_list = self.get_words_list(part_of_speech=part_of_speech, ext_word_list=ext_word_list)

if unique:
unique_samples = cast(List[str], self.random_sample(word_list, length=nb))
Expand Down
8 changes: 7 additions & 1 deletion faker/proxy.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1729,7 +1729,13 @@ class Faker:
:sample: ext_word_list=['abc', 'def', 'ghi', 'jkl']
"""
...
def words(self, nb: int = ..., ext_word_list: Optional[List[str]] = ..., unique: bool = ...) -> List[str]:
def words(
self,
nb: int = ...,
ext_word_list: Optional[List[str]] = ...,
part_of_speech: Optional[str] = ...,
unique: bool = ...,
) -> List[str]:
"""
Generate a tuple of words.
Expand Down

0 comments on commit ffa364b

Please sign in to comment.