Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
wimglenn committed Nov 26, 2023
1 parent 8bd78b0 commit 44e9635
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 36 deletions.
2 changes: 1 addition & 1 deletion aocd/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys
from typing import TYPE_CHECKING
from functools import partial
from typing import TYPE_CHECKING

from . import cli
from . import cookies
Expand Down
2 changes: 1 addition & 1 deletion aocd/_compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from importlib.metadata import entry_points
import sys
from importlib.metadata import entry_points

# typing.Self added in 3.11
if sys.version_info >= (3, 11):
Expand Down
5 changes: 4 additions & 1 deletion aocd/_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import TYPE_CHECKING, Literal, Optional, Union
from typing import Literal
from typing import Optional
from typing import TYPE_CHECKING
from typing import Union

if TYPE_CHECKING:
import numpy as np
Expand Down
5 changes: 4 additions & 1 deletion aocd/examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
import logging
import re
import sys
from typing import NamedTuple, Optional, Callable, Union
from dataclasses import dataclass
from datetime import datetime
from itertools import zip_longest
from typing import Callable
from typing import NamedTuple
from typing import Optional
from typing import Union

import bs4

Expand Down
4 changes: 3 additions & 1 deletion aocd/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import re
import traceback
from logging import getLogger
from typing import Optional, Union, Literal
from typing import Literal
from typing import Optional
from typing import Union

from ._ipykernel import get_ipynb_path
from .exceptions import AocdError
Expand Down
19 changes: 16 additions & 3 deletions aocd/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,24 @@
from itertools import count
from pathlib import Path
from textwrap import dedent
from typing import TYPE_CHECKING, Callable, Generator, Optional, Protocol, TypeVar, TypedDict, cast, Iterable, Union, Literal
from typing import Callable
from typing import cast
from typing import Generator
from typing import Iterable
from typing import Literal
from typing import Optional
from typing import Protocol
from typing import TYPE_CHECKING
from typing import TypedDict
from typing import TypeVar
from typing import Union

from . import examples as _examples # must rename import to avoid conflict w/ examples method
from ._compat import get_entry_points, Self
from ._types import _Answer, _Part, _LoosePart
from ._compat import get_entry_points
from ._compat import Self
from ._types import _Answer
from ._types import _LoosePart
from ._types import _Part
from .exceptions import AocdError
from .exceptions import DeadTokenError
from .exceptions import ExampleParserError
Expand Down
3 changes: 2 additions & 1 deletion aocd/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@

import urllib3

from ._types import _Answer
from ._types import _Part
from .get import current_day
from .get import most_recent_year
from .models import default_user
from .models import Puzzle
from .models import User
from ._types import _Part, _Answer


log = logging.getLogger(__name__)
Expand Down
10 changes: 9 additions & 1 deletion aocd/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
from functools import partial
from importlib.metadata import EntryPoint
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Iterable, Mapping, NoReturn, Optional, TypeVar, Union, cast
from typing import Callable
from typing import cast
from typing import Iterable
from typing import Mapping
from typing import NoReturn
from typing import Optional
from typing import TYPE_CHECKING
from typing import TypeVar
from typing import Union

import pebble.concurrent

Expand Down
12 changes: 8 additions & 4 deletions aocd/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import argparse
import logging
import os
from pathlib import Path
import platform
import shutil
import sys
Expand All @@ -12,16 +11,21 @@
from importlib.metadata import entry_points
from importlib.metadata import version
from itertools import cycle
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import Mapping, Optional, Union
from typing import Mapping
from typing import Optional
from typing import Union
from zoneinfo import ZoneInfo

import bs4
import urllib3

from ._compat import get_plugins as get_plugins # import using same name to tell the type checker we intend to export this (so other modules can import it)
from ._types import _Part, _LoosePart
from .exceptions import AocdError, DeadTokenError
from ._types import _LoosePart
from ._types import _Part
from .exceptions import AocdError
from .exceptions import DeadTokenError


log = logging.getLogger(__name__)
Expand Down
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from pathlib import Path
from typing import Generator

import pook as pook_mod
import pytest
from pytest_mock import MockerFixture
from pytest_mock.plugin import MockType

from aocd.models import User
from aocd.utils import http

from pathlib import Path
from pytest_mock.plugin import MockType


@pytest.fixture(autouse=True)
def mocked_sleep(mocker: MockerFixture) -> MockType:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_aocd.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import functools

import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
import pytest

import aocd

Expand Down
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pook as pook_mod
import pytest
from pytest_mock import MockerFixture

from aocd.cli import main
import pook as pook_mod

def test_main_invalid_date(mocker: MockerFixture, capsys: pytest.CaptureFixture[str]) -> None:
mocker.patch("sys.argv", ["aocd", "1", "2014"])
Expand Down
2 changes: 1 addition & 1 deletion tests/test_date_finding.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

from freezegun.api import FrozenDateTimeFactory
import pytest
from freezegun.api import FrozenDateTimeFactory

from aocd.exceptions import AocdError
from aocd.get import current_day
Expand Down
4 changes: 2 additions & 2 deletions tests/test_example_parser.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bs4
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
import pook as pook_mod
import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture

from aocd.examples import main
from aocd.examples import Page
Expand Down
8 changes: 4 additions & 4 deletions tests/test_get_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
import io
import logging
import os
from pathlib import Path
import threading
from importlib.metadata import version
from pathlib import Path

from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
import pook as pook_mod
import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture

import aocd
from aocd.exceptions import AocdError
from aocd.exceptions import PuzzleLockedError
import aocd



Expand Down
6 changes: 3 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import logging
from datetime import datetime
from datetime import timedelta
from pathlib import Path
import logging

from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
import numpy as np
import pook as pook_mod
import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture

from aocd._types import _Answer
from aocd.exceptions import AocdError
Expand Down
4 changes: 2 additions & 2 deletions tests/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path

from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
import pook as pook_mod
import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture

from aocd._types import _Answer
from aocd.runner import _process_wrapper
Expand Down
6 changes: 3 additions & 3 deletions tests/test_submit.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from pathlib import Path
import json
import logging
from pathlib import Path

import pook as pook_mod
import pytest
from freezegun.api import FrozenDateTimeFactory
from pytest_mock import MockerFixture
from pytest_mock.plugin import MockType
import pook as pook_mod
import pytest

from aocd.exceptions import AocdError
from aocd.post import submit
Expand Down
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pathlib import Path
import platform
from pathlib import Path

from freezegun import freeze_time
import pook as pook_mod
import pytest
from freezegun import freeze_time

from aocd.exceptions import DeadTokenError
from aocd.utils import atomic_write_file
Expand Down

0 comments on commit 44e9635

Please sign in to comment.