Skip to content

Commit

Permalink
chg: Use new annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Jan 15, 2024
1 parent 3e7f759 commit 87ebef3
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 39 deletions.
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: "tests/data"
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/asottile/pyupgrade
rev: v2.31.1
hooks:
- id: pyupgrade
args: [--py38-plus]
4 changes: 4 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
[mypy]
strict = True
warn_return_any = False
show_error_context = True
pretty = True

[mypy-docs.source.*]
ignore_errors = True
50 changes: 20 additions & 30 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion pyproject/__init__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from __future__ import annotations

import argparse
import json
import sys

from .api import PyProject

__all__ = ['PyProject']


def main():
def main() -> None:
parser = argparse.ArgumentParser(description='Query a thing.')
parser.add_argument('--url', type=str, required=True, help='URL of the instance.')
group = parser.add_mutually_exclusive_group(required=True)
Expand Down
11 changes: 6 additions & 5 deletions pyproject/api.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from __future__ import annotations

from importlib.metadata import version
from typing import Dict, Optional
from typing import Any
from urllib.parse import urljoin, urlparse

import requests


class PyProject():

def __init__(self, root_url: str, useragent: Optional[str]=None,
*, proxies: Optional[Dict[str, str]]=None):
def __init__(self, root_url: str, useragent: str | None=None,
*, proxies: dict[str, str] | None=None):
'''Query a specific instance.
:param root_url: URL of the instance to query.
Expand All @@ -38,7 +39,7 @@ def is_up(self) -> bool:
return False
return r.status_code == 200

def redis_up(self) -> Dict:
def redis_up(self) -> dict[str, Any]:
'''Check if redis is up and running'''
r = self.session.get(urljoin(self.root_url, 'redis_up'))
return r.json()
5 changes: 2 additions & 3 deletions tests/test_web.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import unittest

Expand All @@ -8,9 +7,9 @@

class TestBasic(unittest.TestCase):

def setUp(self):
def setUp(self) -> None:
self.client = PyProject(root_url="http://127.0.0.1:9999")

def test_up(self):
def test_up(self) -> None:
self.assertTrue(self.client.is_up)
self.assertTrue(self.client.redis_up())

0 comments on commit 87ebef3

Please sign in to comment.