Skip to content

Commit

Permalink
Fix implicit Optional issues (#1748)
Browse files Browse the repository at this point in the history
* Move show-column-numbers into config

* Fix various implicit Optional issues
  • Loading branch information
palfrey authored Nov 14, 2022
1 parent d01a1b9 commit 548d85a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ jobs:
uses: liskin/gh-problem-matcher-wrap@v1
with:
linters: mypy
run: mypy --show-column-numbers --install-types --non-interactive --config mypy.ini faker
run: mypy --install-types --non-interactive --config mypy.ini faker

test_ubuntu:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion faker/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def create(
cls,
locale: Optional[str] = None,
providers: Optional[List[str]] = None,
generator: Generator = None,
generator: Optional[Generator] = None,
includes: Optional[List[str]] = None,
# Should we use weightings (more realistic) or weight every element equally (faster)?
# By default, use weightings for backwards compatibility & realism
Expand Down
2 changes: 1 addition & 1 deletion faker/providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
class BaseProvider:

__provider__ = "base"
__lang__ = None
__lang__: Optional[str] = None
__use_weighting__ = False

# Locales supported by Linux Mint from `/usr/share/i18n/SUPPORTED`
Expand Down
2 changes: 1 addition & 1 deletion faker/providers/date_time/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ def date(self, pattern: str = "%Y-%m-%d", end_datetime: Optional[DateParseType]
"""
return self.date_time(end_datetime=end_datetime).strftime(pattern)

def date_object(self, end_datetime: datetime = None) -> dtdate:
def date_object(self, end_datetime: Optional[datetime] = None) -> dtdate:
"""
Get a date object between January 1, 1970 and now
:example: datetime.date(2016, 9, 20)
Expand Down
4 changes: 2 additions & 2 deletions faker/providers/lorem/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Provider(BaseProvider):
def words(
self,
nb: int = 3,
part_of_speech: str = None,
part_of_speech: Optional[str] = None,
ext_word_list: Optional[Sequence[str]] = None,
unique: bool = False,
) -> List[str]:
Expand Down Expand Up @@ -73,7 +73,7 @@ def words(
samples = cast(List[str], self.random_choices(word_list, length=nb))
return samples

def word(self, part_of_speech: str = None, ext_word_list: Optional[Sequence[str]] = None) -> str:
def word(self, part_of_speech: Optional[str] = None, ext_word_list: Optional[Sequence[str]] = None) -> str:
"""Generate a word.
This method uses |words| under the hood with the ``nb`` argument set to
Expand Down
4 changes: 2 additions & 2 deletions faker/providers/misc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def psv(
delimiter="|",
)

def json(self, data_columns: List = None, num_rows: int = 10, indent: int = None) -> str:
def json(self, data_columns: Optional[List] = None, num_rows: int = 10, indent: Optional[int] = None) -> str:
"""
Generate random JSON structure values.
Expand Down Expand Up @@ -590,7 +590,7 @@ def create_json_structure(data_columns: Union[Dict, List]) -> dict:
data = [create_json_structure(data_columns) for _ in range(num_rows)]
return json.dumps(data, indent=indent)

def fixed_width(self, data_columns: list = None, num_rows: int = 10, align: str = "left") -> str:
def fixed_width(self, data_columns: Optional[list] = None, num_rows: int = 10, align: str = "left") -> str:
"""
Generate random fixed width values.
Expand Down
3 changes: 2 additions & 1 deletion mypy.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ allow_redefinition = True
pretty = True
follow_imports=silent
ignore_missing_imports = True
show_error_codes = True
show_error_codes = True
show_column_numbers = True

0 comments on commit 548d85a

Please sign in to comment.