Skip to content

Commit

Permalink
chore(deps): update project dependencies
Browse files Browse the repository at this point in the history
Make the following changes:
- Update the project dependencies to the latest versions where applicable.
- Upgrade the project's minimum runtime from Python 3.9 to Python 3.10.
- Update the project sources to use Python 3.10 (and above) syntax where applicable.
  • Loading branch information
kennedykori committed Apr 8, 2023
1 parent 3408edd commit eeb48e6
Show file tree
Hide file tree
Showing 36 changed files with 166 additions and 164 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

strategy:
matrix:
python-version: ["3.9", "3.10"]
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v3
- name: Set up project using python ${{ matrix.python-version }}
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ jobs:
run: |
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.10 python3.10-dev python3.10-distutils nodejs
sudo apt-get install python3.11 python3.11-dev python3.11-distutils nodejs
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.10 2
sudo update-alternatives --set python /usr/bin/python3.10
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.11 2
sudo update-alternatives --set python /usr/bin/python3.11
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 2
sudo update-alternatives --set python3 /usr/bin/python3.10
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10
python3.10 -m pip install -r requirements/dev.txt
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.11 2
sudo update-alternatives --set python3 /usr/bin/python3.11
curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
python3.11 -m pip install -r requirements/build.txt
npm install @semantic-release/changelog @semantic-release/git conventional-changelog-conventionalcommits
- name: Package the app
Expand Down
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/psf/black
rev: 22.6.0
rev: 23.3.0
hooks:
- id: black

- repo: https://github.com/timothycrosley/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/asottile/pyupgrade
rev: v2.37.3
rev: v3.3.1
hooks:
- id: pyupgrade
args: [--py38-plus]
args: [--py310-plus]

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
- repo: https://github.com/pycqa/flake8
rev: 6.0.0
hooks:
- id: flake8
args: ["--config=tox.ini"]
Expand Down
16 changes: 8 additions & 8 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Mapping, Sequence
from logging.config import dictConfig
from typing import Any, Final, Optional, cast
from typing import Any, Final, cast

import yaml
from yaml import Loader
Expand Down Expand Up @@ -127,7 +127,7 @@ class _DefaultTransportFactoryInitializer(SettingInitializer):
def setting(self) -> str:
return _DEFAULT_TRANSPORT_FACTORY_CONFIG_KEY

def execute(self, an_input: Optional[str]) -> Any:
def execute(self, an_input: str | None) -> Any:
# If the default transport setting has not been provided or is empty,
# do nothing.
if not an_input:
Expand Down Expand Up @@ -162,7 +162,7 @@ class _LoggingInitializer(SettingInitializer):
def setting(self) -> str:
return _LOGGING_CONFIG_KEY

def execute(self, an_input: Optional[Mapping[str, Any]]) -> Any:
def execute(self, an_input: Mapping[str, Any] | None) -> Any:
logging_config: dict[str, Any] = dict(
an_input or _DEFAULT_CONFIG[self.setting]
)
Expand All @@ -180,12 +180,12 @@ class _SupportedDataSourceTypesInitializer(SettingInitializer):
def setting(self) -> str:
return _SUPPORTED_DATA_SOURCE_TYPES_CONFIG_KEY

def execute(self, an_input: Optional[Sequence[str]]) -> Any:
def execute(self, an_input: Sequence[str] | None) -> Any:
supported_dst: Sequence[str] = (
an_input or _DEFAULT_CONFIG[self.setting]
)
global registry
_dst: DataSourceType
_dst: DataSourceType # noqa: F842
registry.data_source_types = {
_dst.code: _dst
for _dst in map(
Expand Down Expand Up @@ -224,9 +224,9 @@ def _dotted_path_to_data_source_type_klass(


def setup(
initial_settings: Optional[Mapping[str, Any]] = None,
settings_initializers: Optional[Sequence[SettingInitializer]] = None,
config_file_path: Optional[str] = None,
initial_settings: Mapping[str, Any] | None = None,
settings_initializers: Sequence[SettingInitializer] | None = None,
config_file_path: str | None = None,
) -> None:
"""
Set up the application and ready it for use.
Expand Down
3 changes: 1 addition & 2 deletions app/__main__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from argparse import ArgumentParser
from collections.abc import Sequence
from typing import Optional

import app
from app.__version__ import __title__, __version__
Expand Down Expand Up @@ -76,7 +75,7 @@ def argparse_factory(prog_name: str = __title__) -> ArgumentParser:


def main_pipeline_factory(
transport: Optional[Transport] = None,
transport: Transport | None = None,
) -> Pipeline[Sequence[DataSourceType], Sequence[UploadExtractResult]]:
"""A factory for the main application pipeline.
Expand Down
14 changes: 7 additions & 7 deletions app/core/domain.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping, Sequence
from functools import lru_cache
from typing import Any, Generic, Optional, TypeVar
from typing import Any, Generic, TypeVar

from typing_inspect import is_optional_type

Expand Down Expand Up @@ -136,8 +136,8 @@ class ExtractMetadata(
"""

name: str
description: Optional[str]
preferred_uploads_name: Optional[str]
description: str | None
preferred_uploads_name: str | None

@property
@abstractmethod
Expand All @@ -152,7 +152,7 @@ def data_source(self) -> "DataSource":

def get_upload_meta_extra_init_kwargs( # noqa
self,
) -> Optional[Mapping[str, Any]]:
) -> Mapping[str, Any] | None:
"""
Return an optional mapping of extra keyword arguments to be used when
initializing the :class:`upload metadata <UploadMetadata>` instance
Expand Down Expand Up @@ -206,7 +206,7 @@ class DataSource(

id: str
name: str
description: Optional[str]
description: str | None

@property
@abstractmethod
Expand Down Expand Up @@ -336,7 +336,7 @@ def extract_metadata(self) -> ExtractMetadata[Any, _RT]:

def get_upload_chunk_extra_init_kwargs( # noqa
self,
) -> Optional[Mapping[str, Any]]:
) -> Mapping[str, Any] | None:
"""
Return an optional mapping of extra keyword arguments to be used when
initializing the :class:`upload chunk <UploadChunk>` instance
Expand Down Expand Up @@ -399,7 +399,7 @@ class DataSourceType(AbstractDomainObject, metaclass=ABCMeta):
"""

name: str
description: Optional[str]
description: str | None

@property
@abstractmethod
Expand Down
13 changes: 5 additions & 8 deletions app/core/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from typing import Optional


class IDRClientException(Exception):
"""Base exception for most explicit exceptions raised by this app."""

def __init__(self, message: Optional[str] = None, *args):
def __init__(self, message: str | None = None, *args):
"""Initialize an ``IDRClientException`` with the given parameters.
:param message: An optional error message.
:param args: args to pass to forward to the base exception.
"""
self._message: Optional[str] = message
self._message: str | None = message
super().__init__(self._message, *args)

@property
def message(self) -> Optional[str]:
def message(self) -> str | None:
"""
Return the error message passed to this exception at initialization
or ``None`` if one was not given.
Expand All @@ -40,7 +37,7 @@ class DataSourceDisposedError(ExtractionOperationError):
"""

def __init__(
self, message: Optional[str] = "Data source is disposed.", *args
self, message: str | None = "Data source is disposed.", *args
):
"""Initialize an ``DataSourceDisposedError`` with the given parameters.
Expand All @@ -63,7 +60,7 @@ class TransportClosedError(TransportError):
made.
"""

def __init__(self, message: Optional[str] = "Transport closed.", *args):
def __init__(self, message: str | None = "Transport closed.", *args):
"""Initialize an ``TransportClosedError`` with the given parameters.
:param message: An optional error message.
Expand Down
10 changes: 5 additions & 5 deletions app/core/mixins.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping
from types import TracebackType
from typing import Any, ContextManager, Generic, Optional, TypeVar
from typing import Any, ContextManager, Generic, TypeVar

from .task import Task

Expand All @@ -23,10 +23,10 @@ class Disposable(ContextManager, metaclass=ABCMeta):

def __exit__(
self,
exc_type: Optional[type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[TracebackType],
) -> Optional[bool]:
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: TracebackType | None,
) -> bool | None:
self.dispose()
return False

Expand Down
6 changes: 3 additions & 3 deletions app/core/transport.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import ABCMeta, abstractmethod
from collections.abc import Mapping, Sequence
from typing import Any, Optional
from typing import Any

from .domain import (
DataSource,
Expand Down Expand Up @@ -101,7 +101,7 @@ def post_upload_chunk(
upload_metadata: UploadMetadata,
chunk_index: int,
chunk_content: bytes,
extra_init_kwargs: Optional[Mapping[str, Any]] = None,
extra_init_kwargs: Mapping[str, Any] | None = None,
**options: TransportOptions,
) -> UploadChunk:
"""
Expand Down Expand Up @@ -133,7 +133,7 @@ def post_upload_metadata(
content_type: str,
org_unit_code: str,
org_unit_name: str,
extra_init_kwargs: Optional[Mapping[str, Any]] = None,
extra_init_kwargs: Mapping[str, Any] | None = None,
**options: TransportOptions,
) -> UploadMetadata:
"""
Expand Down
4 changes: 2 additions & 2 deletions app/imp/sql_data/domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections.abc import Mapping, Sequence
from enum import Enum
from logging import getLogger
from typing import Any, Final, Optional
from typing import Any, Final

import pandas as pd
import pyarrow as pa
Expand Down Expand Up @@ -91,7 +91,7 @@ def __init__(self, **kwargs):
super().__init__(**kwargs)
self._data_source_type: SQLDataSourceType = data_source_type
self._extract_metadata: dict[str, "SQLExtractMetadata"] = dict()
self._engine: Optional[Engine] = None
self._engine: Engine | None = None

def __enter__(self) -> "SQLDataSource":
if self._engine is not None:
Expand Down
11 changes: 5 additions & 6 deletions app/lib/app_registry.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections.abc import Mapping
from typing import Callable, Optional
from collections.abc import Callable, Mapping

from app.core import DataSourceType, Transport

Expand All @@ -26,9 +25,9 @@ class AppRegistry:

def __init__(self):
self._data_source_types: dict[str, DataSourceType] = dict()
self._default_transport_factory: Optional[
self._default_transport_factory: None | (
DefaultTransportFactory
] = None
) = None

@property
def data_source_types(self) -> Mapping[str, DataSourceType]:
Expand All @@ -55,7 +54,7 @@ def data_source_types(
self._data_source_types = dict(**data_source_types)

@property
def default_transport_factory(self) -> Optional[DefaultTransportFactory]:
def default_transport_factory(self) -> DefaultTransportFactory | None:
"""Return the default transport factory for the app if set.
:return: The default transport factory for the app if set or ``None``
Expand All @@ -77,7 +76,7 @@ def default_transport_factory(
self._default_transport_factory = transport_factory

def get_default_transport_factory_or_raise(
self, error_message: Optional[str] = None
self, error_message: str | None = None
) -> DefaultTransportFactory:
"""
Returns the default transport factory if set or raise an
Expand Down
4 changes: 2 additions & 2 deletions app/lib/checkers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from abc import abstractmethod
from collections.abc import Sized
from typing import Optional, Protocol, SupportsFloat, TypeVar
from typing import Protocol, SupportsFloat, TypeVar

# =============================================================================
# TYPES
Expand Down Expand Up @@ -50,7 +50,7 @@ def ensure_greater_than(


def ensure_not_none(
value: Optional[_T], message: str = '"value" cannot be None.'
value: _T | None, message: str = '"value" cannot be None.'
) -> _T:
"""Check that a given value is not ``None``.
Expand Down
4 changes: 2 additions & 2 deletions app/lib/config/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import logging
from collections.abc import Mapping, Sequence
from typing import Any, Optional
from typing import Any

from .exceptions import MissingSettingError
from .setting_initializer import SettingInitializer
Expand Down Expand Up @@ -33,7 +33,7 @@ class Config:
def __init__(
self,
settings: Mapping[str, Any],
settings_initializers: Optional[Sequence[SettingInitializer]] = None,
settings_initializers: Sequence[SettingInitializer] | None = None,
):
"""
Initialize a new :class:`Config` instance. The settings to use are
Expand Down
Loading

0 comments on commit eeb48e6

Please sign in to comment.