Skip to content

Commit

Permalink
fix: Resolve linting issues related to changing linter versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
DanCardin committed Aug 17, 2021
1 parent d0d7685 commit 59a983f
Show file tree
Hide file tree
Showing 8 changed files with 424 additions and 352 deletions.
721 changes: 399 additions & 322 deletions poetry.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,15 @@ pymysql = {version = ">=1.0", optional = true}
black = {version = "=>19.3b0", allow-prereleases = true}
coverage = "*"
flake8 = "*"
isort = "*"
mypy = {version = "*", python = ">=3.5"}
isort = ">=5.0"
mypy = {version = "0.910", python = ">=3.5"}
pydocstyle = {version = "*", python = ">=3.5"}
sqlalchemy-stubs = {version = "*", python = ">=3.5"}
pytest-xdist = "*"
pytest-asyncio = "^0.15.1"
types-six = "^1.16.0"
types-PyMySQL = "^1.0.2"
types-redis = "^3.5.6"

[tool.poetry.extras]
postgres = ['psycopg2']
Expand All @@ -74,14 +77,11 @@ pytest_mock_resources = "pytest_mock_resources"
pmr = "pytest_mock_resources.cli:main"

[tool.isort]
default_section = 'FIRSTPARTY'
include_trailing_comma = true
indent = ' '
length_sort = false
profile = 'black'
known_first_party = 'app,tests'
line_length = 100
float_to_top = true
float_to_top=true
order_by_type = false
known_first_party = 'tests'
use_parentheses = true

[tool.black]
Expand Down
18 changes: 5 additions & 13 deletions src/pytest_mock_resources/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,21 +87,13 @@ def __getattr__(self, attr):
try:
import pymysql
except ImportError:
pymysql = ImportAdaptor("pymysql", "mysql")
pymysql = ImportAdaptor("pymysql", "mysql") # type: ignore

try:
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
from sqlalchemy.ext.asyncio import AsyncSession, create_async_engine
except ImportError:
fail_message = (
"Cannot use sqlalchemy async features with SQLAlchemy < 1.4.\n"
)
fail_message = "Cannot use sqlalchemy async features with SQLAlchemy < 1.4.\n"
create_async_engine = ImportAdaptor(
"SQLAlchemy",
"SQLAlchemy >= 1.4",
fail_message=fail_message
"SQLAlchemy", "SQLAlchemy >= 1.4", fail_message=fail_message
)
AsyncSession = ImportAdaptor(
"SQLAlchemy",
"SQLAlchemy >= 1.4",
fail_message=fail_message
)
AsyncSession = ImportAdaptor("SQLAlchemy", "SQLAlchemy >= 1.4", fail_message=fail_message)
8 changes: 4 additions & 4 deletions src/pytest_mock_resources/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import functools
import os
import socket

import functools
from typing import Dict, Iterable

_DOCKER_HOST = "host.docker.internal"

Expand Down Expand Up @@ -50,8 +50,8 @@ def wrapper(self):


class DockerContainerConfig:
_fields = {"image", "host", "port", "ci_port"}
_fields_defaults = {}
_fields: Iterable = {"image", "host", "port", "ci_port"}
_fields_defaults: Dict = {}

def __init__(self, **kwargs):
for field in self._fields:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import abc
import fnmatch
from typing import Tuple

import attr
import six
Expand All @@ -10,7 +11,7 @@
from sqlalchemy.sql.ddl import CreateSchema
from sqlalchemy.sql.schema import Table

from pytest_mock_resources.compat import create_async_engine, AsyncSession
from pytest_mock_resources.compat import AsyncSession, create_async_engine


@six.add_metaclass(abc.ABCMeta)
Expand Down Expand Up @@ -75,7 +76,7 @@ def run(self, engine_manager):
class EngineManager(object):
engine = attr.ib()
ordered_actions = attr.ib(default=attr.Factory(tuple))
tables = attr.ib(default=None, converter=attr.converters.optional(tuple))
tables: Tuple = attr.ib(default=None, converter=attr.converters.optional(tuple))
session = attr.ib(default=False)
default_schema = attr.ib(default=None)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
# See https://github.com/spulec/moto/issues/3292#issuecomment-770682026
@pytest.fixture(autouse=True)
def set_aws_region(monkeypatch):
monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1")
monkeypatch.setenv("AWS_DEFAULT_REGION", "us-east-1")
5 changes: 3 additions & 2 deletions tests/fixture/database/test_ordered_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ def test_metadata_only(postgres_metadata_only):
assert [] == result


postgres_ordered_actions_async = create_postgres_fixture(rows, row_dependant_statements, additional_rows, async_=True)
postgres_ordered_actions_async = create_postgres_fixture(
rows, row_dependant_statements, additional_rows, async_=True
)

postgres_session_function_async = create_postgres_fixture(Base, session_function, async_=True)

Expand All @@ -91,7 +93,6 @@ async def test_ordered_actions_aysnc(postgres_ordered_actions_async, run):
await conn.execute(text("SELECT * FROM user1"))



# Run the test 5 times to ensure fixture is stateless
@pytest.mark.asyncio
@pytest.mark.parametrize("run", range(5))
Expand Down
1 change: 1 addition & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from unittest import mock

from pytest_mock_resources.config import DockerContainerConfig, fallback, get_env_config

_DOCKER_HOST = "host.docker.internal"
Expand Down

0 comments on commit 59a983f

Please sign in to comment.