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

add flake8-annotations package for type linting #1061

Merged
merged 7 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ repos:
rev: 4.0.1
hooks:
- id: flake8
additional_dependencies: [flake8-bugbear]
additional_dependencies: [flake8-bugbear,flake8-annotations]
- repo: https://github.com/pre-commit/mirrors-mypy
rev: 'v0.910-1'
hooks:
Expand Down
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dateparser==1.*
flake8-annotations==2.*
pre-commit==2.*
pytest==6.*
pytest-cov==3.*
Expand Down
40 changes: 20 additions & 20 deletions tests/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2341,7 +2341,7 @@ def test_years(self):

# Fixtures for Dehumanize
@pytest.fixture(scope="class")
def locale_list_no_weeks():
def locale_list_no_weeks() -> list[str]:
jadchaar marked this conversation as resolved.
Show resolved Hide resolved
tested_langs = [
"en",
"en-us",
Expand Down Expand Up @@ -2455,7 +2455,7 @@ def locale_list_no_weeks():


@pytest.fixture(scope="class")
def locale_list_with_weeks():
def locale_list_with_weeks() -> list[str]:
tested_langs = [
"en",
"en-us",
Expand Down Expand Up @@ -2517,7 +2517,7 @@ def locale_list_with_weeks():


class TestArrowDehumanize:
def test_now(self, locale_list_no_weeks):
def test_now(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2535,7 +2535,7 @@ def test_now(self, locale_list_no_weeks):
assert arw.dehumanize(second_ago_string, locale=lang) == arw
assert arw.dehumanize(second_future_string, locale=lang) == arw

def test_seconds(self, locale_list_no_weeks):
def test_seconds(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2553,7 +2553,7 @@ def test_seconds(self, locale_list_no_weeks):
assert arw.dehumanize(second_ago_string, locale=lang) == second_ago
assert arw.dehumanize(second_future_string, locale=lang) == second_future

def test_minute(self, locale_list_no_weeks):
def test_minute(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2571,7 +2571,7 @@ def test_minute(self, locale_list_no_weeks):
assert arw.dehumanize(minute_ago_string, locale=lang) == minute_ago
assert arw.dehumanize(minute_future_string, locale=lang) == minute_future

def test_minutes(self, locale_list_no_weeks):
def test_minutes(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2589,7 +2589,7 @@ def test_minutes(self, locale_list_no_weeks):
assert arw.dehumanize(minute_ago_string, locale=lang) == minute_ago
assert arw.dehumanize(minute_future_string, locale=lang) == minute_future

def test_hour(self, locale_list_no_weeks):
def test_hour(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2605,7 +2605,7 @@ def test_hour(self, locale_list_no_weeks):
assert arw.dehumanize(hour_ago_string, locale=lang) == hour_ago
assert arw.dehumanize(hour_future_string, locale=lang) == hour_future

def test_hours(self, locale_list_no_weeks):
def test_hours(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2621,7 +2621,7 @@ def test_hours(self, locale_list_no_weeks):
assert arw.dehumanize(hour_ago_string, locale=lang) == hour_ago
assert arw.dehumanize(hour_future_string, locale=lang) == hour_future

def test_week(self, locale_list_with_weeks):
def test_week(self, locale_list_with_weeks: list[str]):

for lang in locale_list_with_weeks:

Expand All @@ -2637,7 +2637,7 @@ def test_week(self, locale_list_with_weeks):
assert arw.dehumanize(week_ago_string, locale=lang) == week_ago
assert arw.dehumanize(week_future_string, locale=lang) == week_future

def test_weeks(self, locale_list_with_weeks):
def test_weeks(self, locale_list_with_weeks: list[str]):

for lang in locale_list_with_weeks:

Expand All @@ -2653,7 +2653,7 @@ def test_weeks(self, locale_list_with_weeks):
assert arw.dehumanize(week_ago_string, locale=lang) == week_ago
assert arw.dehumanize(week_future_string, locale=lang) == week_future

def test_year(self, locale_list_no_weeks):
def test_year(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2669,7 +2669,7 @@ def test_year(self, locale_list_no_weeks):
assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
assert arw.dehumanize(year_future_string, locale=lang) == year_future

def test_years(self, locale_list_no_weeks):
def test_years(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2685,7 +2685,7 @@ def test_years(self, locale_list_no_weeks):
assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
assert arw.dehumanize(year_future_string, locale=lang) == year_future

def test_gt_than_10_years(self, locale_list_no_weeks):
def test_gt_than_10_years(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2701,7 +2701,7 @@ def test_gt_than_10_years(self, locale_list_no_weeks):
assert arw.dehumanize(year_ago_string, locale=lang) == year_ago
assert arw.dehumanize(year_future_string, locale=lang) == year_future

def test_mixed_granularity(self, locale_list_no_weeks):
def test_mixed_granularity(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2719,7 +2719,7 @@ def test_mixed_granularity(self, locale_list_no_weeks):
assert arw.dehumanize(past_string, locale=lang) == past
assert arw.dehumanize(future_string, locale=lang) == future

def test_mixed_granularity_hours(self, locale_list_no_weeks):
def test_mixed_granularity_hours(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2737,7 +2737,7 @@ def test_mixed_granularity_hours(self, locale_list_no_weeks):
assert arw.dehumanize(past_string, locale=lang) == past
assert arw.dehumanize(future_string, locale=lang) == future

def test_mixed_granularity_day(self, locale_list_no_weeks):
def test_mixed_granularity_day(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2755,7 +2755,7 @@ def test_mixed_granularity_day(self, locale_list_no_weeks):
assert arw.dehumanize(past_string, locale=lang) == past
assert arw.dehumanize(future_string, locale=lang) == future

def test_mixed_granularity_day_hour(self, locale_list_no_weeks):
def test_mixed_granularity_day_hour(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand Down Expand Up @@ -2812,7 +2812,7 @@ def test_normalized_locale(self):
assert arw.dehumanize(second_future_string, locale="zh_hk") == second_future

# Ensures relative units are required in string
def test_require_relative_unit(self, locale_list_no_weeks):
def test_require_relative_unit(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand All @@ -2834,7 +2834,7 @@ def test_require_relative_unit(self, locale_list_no_weeks):
arw.dehumanize(second_future_string, locale=lang)

# Test for scrambled input
def test_scrambled_input(self, locale_list_no_weeks):
def test_scrambled_input(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand Down Expand Up @@ -2862,7 +2862,7 @@ def test_scrambled_input(self, locale_list_no_weeks):
with pytest.raises(ValueError):
arw.dehumanize(second_future_string, locale=lang)

def test_no_units_modified(self, locale_list_no_weeks):
def test_no_units_modified(self, locale_list_no_weeks: list[str]):

for lang in locale_list_no_weeks:

Expand Down
4 changes: 2 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ multi_line_output = 3
include_trailing_comma = true

[flake8]
per-file-ignores = arrow/__init__.py:F401
ignore = E203,E501,W503
per-file-ignores = arrow/__init__.py:F401,tests/*:ANN001,ANN201
ignore = E203,E501,W503,ANN101,ANN102