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

Bump ruff to version 0.2.1 #323

Merged
merged 4 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 9 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.2.0
rev: v0.2.1
hooks:
- id: ruff
args:
Expand All @@ -20,13 +20,17 @@ repos:
rev: v4.5.0
hooks:
- id: end-of-file-fixer
- id: mixed-line-ending
- id: trailing-whitespace
- id: check-yaml
- id: check-json
- id: check-toml
- id: pretty-format-json
args:
- --no-sort-keys
- id: no-commit-to-branch
args:
- --branch=master
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.33.0
hooks:
- id: yamllint
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v4.0.0-alpha.8
hooks:
Expand Down
59 changes: 0 additions & 59 deletions .yamllint

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Apache License
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 Maciej Bieniek
Copyright 2024 Maciej Bieniek

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion accuweather/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
class AccuWeather:
"""Main class to perform AccuWeather API requests."""

def __init__( # noqa: PLR0913
def __init__(
self,
api_key: str,
session: ClientSession,
Expand Down
2 changes: 1 addition & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
logging.basicConfig(level=logging.DEBUG)


async def main():
async def main() -> None:
"""Run main function."""
async with ClientSession() as websession:
try:
Expand Down
69 changes: 15 additions & 54 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,66 +24,27 @@ warn_unreachable = true
[tool.ruff]
target-version = "py310"

select = [
"A", # flake8-builtins
"ARG", # flake8-unused-arguments
"B", # flake8-bugbear
"BLE", # flake8-blind-except
"C", # complexity
"C4", # flake8-comprehensions
"C90", # mccabe
"D", # docstrings
"DJ", # flake8-django
"DTZ", # flake8-datetimez
"E", # pycodestyle
"ERA", # eradicate
"EXE", # flake8-executable
"F", # pyflakes/autoflake
"FBT", # flake8-boolean-trap
"G", # flake8-logging-format
"I", # isort
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"ISC", # flake8-implicit-str-concat
"N", # pep8-naming
"NPY", # NumPy-specific rules
"PD", # pandas-vet
"PGH", # pygrep-hooks
"PIE", # flake8-pie
"PL", # Pylint
"PT", # flake8-pytest-style
"PYI", # flake8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"S", # flake8-bandit
"SIM", # flake8-simplify
"SLF", # flake8-self
"T10", # flake8-debugger
"T20", # flake8-print
"TID", # flake8-tidy-imports
"TRY", # tryceratops
"UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]
lint.select = ["ALL"]

ignore = [
lint.ignore = [
"ANN101", # Missing type annotation for `self` in method
"ANN102", # Missing type annotation for `cls` in classmethod
"COM812", # Trailing comma missing
"D203", # 1 blank line required before class docstring
"D213", # Multi-line docstring summary should start at the second line
"D404", # First word of the docstring should not be This
"D406", # Section name should end with a newline
"D407", # Section name underlining
"D411", # Missing blank line before section
"FBT001", # Boolean positional arg in function definition
"FBT002", # Boolean default value in function definition
"EM101", # Exception must not use a string literal, assign to variable first
"EM102", # Exception must not use an f-string literal, assign to variable first
"ISC001", # Single line implicit string concatenation
"PT023", # Use `@pytest.mark.asyncio()` over `@pytest.mark.asyncio`
"PLR0913", # Too many arguments to function call
"PTH123", # `open()` should be replaced by `Path.open()`
"TCH002", # Move third-party import into a type-checking block
"TRY003", # Avoid specifying long messages outside the exception class
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed
"FBT001", # Boolean-typed positional argument in function definition
"FBT002", # Boolean default positional argument in function definition
]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"tests/*" = [
"PLR2004", # Magic value used in comparison
"S101", # Use of `assert` detected
Expand All @@ -92,7 +53,7 @@ ignore = [
"T201", # `print` found
]

[tool.ruff.mccabe]
[tool.ruff.lint.mccabe]
max-complexity = 25

[tool.coverage.run]
Expand Down
2 changes: 1 addition & 1 deletion requirements-test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ pytest-cov==4.1.0
pytest-error-for-skips==2.0.2
pytest-timeout==2.2.0
pytest==7.4.4
ruff==0.1.14
ruff==0.2.1
55 changes: 31 additions & 24 deletions tests/test_init.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Tests for accuweather package."""
from http import HTTPStatus
from typing import Any

import aiohttp
import orjson
Expand All @@ -24,35 +25,35 @@


@pytest.fixture()
def location_data():
def location_data() -> dict[str, Any]:
"""Location data fixture."""
with open("tests/fixtures/location_data.json", encoding="utf-8") as file:
return orjson.loads(file.read())


@pytest.fixture()
def current_condition_data():
def current_condition_data() -> dict[str, Any]:
"""Weather current condition data fixture."""
with open("tests/fixtures/current_condition_data.json", encoding="utf-8") as file:
return orjson.loads(file.read())


@pytest.fixture()
def daily_forecast_data():
def daily_forecast_data() -> dict[str, Any]:
"""Daily forecast data fixture."""
with open("tests/fixtures/daily_forecast_data.json", encoding="utf-8") as file:
return orjson.loads(file.read())


@pytest.fixture()
def hourly_forecast_data():
def hourly_forecast_data() -> list[dict[str, Any]]:
"""Hourly forecast data fixture."""
with open("tests/fixtures/hourly_forecast_data.json", encoding="utf-8") as file:
return orjson.loads(file.read())


@pytest.mark.asyncio
async def test_get_location(location_data):
@pytest.mark.asyncio()
async def test_get_location(location_data: dict[str, Any]) -> None:
"""Test with valid location data."""
session = aiohttp.ClientSession()

Expand All @@ -74,8 +75,10 @@ async def test_get_location(location_data):
assert accuweather.requests_remaining == 23


@pytest.mark.asyncio
async def test_get_current_conditions(location_data, current_condition_data):
@pytest.mark.asyncio()
async def test_get_current_conditions(
location_data: dict[str, Any], current_condition_data: dict[str, Any]
) -> None:
"""Test with valid current condition data."""
session = aiohttp.ClientSession()

Expand Down Expand Up @@ -112,8 +115,10 @@ async def test_get_current_conditions(location_data, current_condition_data):
assert accuweather.requests_remaining == 23


@pytest.mark.asyncio
async def test_get_daily_forecast(location_data, daily_forecast_data):
@pytest.mark.asyncio()
async def test_get_daily_forecast(
location_data: dict[str, Any], daily_forecast_data: dict[str, Any]
) -> None:
"""Test with valid daily forecast data."""
session = aiohttp.ClientSession()

Expand Down Expand Up @@ -151,8 +156,10 @@ async def test_get_daily_forecast(location_data, daily_forecast_data):
assert accuweather.requests_remaining == 23


@pytest.mark.asyncio
async def test_get_hourly_forecast(location_data, hourly_forecast_data):
@pytest.mark.asyncio()
async def test_get_hourly_forecast(
location_data: dict[str, Any], hourly_forecast_data: list[dict[str, Any]]
) -> None:
"""Test with valid hourly forecast data."""
session = aiohttp.ClientSession()

Expand Down Expand Up @@ -187,8 +194,8 @@ async def test_get_hourly_forecast(location_data, hourly_forecast_data):
assert accuweather.requests_remaining == 23


@pytest.mark.asyncio
async def test_invalid_api_key_1():
@pytest.mark.asyncio()
async def test_invalid_api_key_1() -> None:
"""Test with invalid API key."""
async with ClientSession() as session:
with pytest.raises(
Expand All @@ -200,8 +207,8 @@ async def test_invalid_api_key_1():
)


@pytest.mark.asyncio
async def test_invalid_api_key_2():
@pytest.mark.asyncio()
async def test_invalid_api_key_2() -> None:
"""Test with invalid API key."""
session = aiohttp.ClientSession()

Expand All @@ -217,8 +224,8 @@ async def test_invalid_api_key_2():
await session.close()


@pytest.mark.asyncio
async def test_invalid_coordinates_1():
@pytest.mark.asyncio()
async def test_invalid_coordinates_1() -> None:
"""Test with invalid coordinates."""
async with ClientSession() as session:
with pytest.raises(
Expand All @@ -227,8 +234,8 @@ async def test_invalid_coordinates_1():
AccuWeather(VALID_API_KEY, session, latitude=55.55, longitude="78.00")


@pytest.mark.asyncio
async def test_invalid_coordinates_2():
@pytest.mark.asyncio()
async def test_invalid_coordinates_2() -> None:
"""Test with invalid coordinates."""
async with ClientSession() as session:
with pytest.raises(
Expand All @@ -237,8 +244,8 @@ async def test_invalid_coordinates_2():
AccuWeather(VALID_API_KEY, session, latitude=199.99, longitude=90.0)


@pytest.mark.asyncio
async def test_api_error():
@pytest.mark.asyncio()
async def test_api_error() -> None:
"""Test with API error."""
payload = {
"Code": "ServiceError",
Expand All @@ -264,8 +271,8 @@ async def test_api_error():
await session.close()


@pytest.mark.asyncio
async def test_requests_exceeded_error():
@pytest.mark.asyncio()
async def test_requests_exceeded_error() -> None:
"""Test with requests exceeded error."""
payload = {
"Code": "ServiceUnavailable",
Expand Down