Skip to content

Commit

Permalink
fix ruff TCH002
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Jun 23, 2023
1 parent 7d1126c commit ec3ecba
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 33 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.267
rev: v0.0.275
hooks:
- id: ruff
args: [--fix]
Expand All @@ -18,7 +18,7 @@ repos:
- id: black-jupyter

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.3.0
rev: v1.4.0
hooks:
- id: mypy

Expand All @@ -35,7 +35,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/codespell-project/codespell
rev: v2.2.4
rev: v2.2.5
hooks:
- id: codespell
stages: [commit, commit-msg]
Expand Down
50 changes: 28 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,27 +65,34 @@ warn_unused_ignores = true
[tool.ruff]
target-version = "py38"
select = [
"A", #flake8-builtins
"B", # flake8-bugbear
"C40", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle error
"F", # pyflakes
"I", # isort
"N", # pep8-naming
"PD", # pandas-vet
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PYI", # flakes8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RUF", # ruff
"SIM", # flake8-simplify
"TID", # tidy imports
"UP", # pyupgrade
"W", # pycodestyle warning
"YTT", # flake8-2020
"B", # flake8-bugbear
"C4", # flake8-comprehensions
"D", # pydocstyle
"E", # pycodestyle error
"EXE", # flake8-executable
"F", # pyflakes
"FA", # flake8-future-annotations
"FLY", # flynt
"I", # isort
"ICN", # flake8-import-conventions
"ISC", # flake8-implicit-str-concat
"PD", # pandas-vet
"PERF", # perflint
"PIE", # flake8-pie
"PL", # pylint
"PT", # flake8-pytest-style
"PYI", # flakes8-pyi
"Q", # flake8-quotes
"RET", # flake8-return
"RSE", # flake8-raise
"RUF", # Ruff-specific rules
"SIM", # flake8-simplify
"SLOT", # flake8-slots
"TCH", # flake8-type-checking
"TID", # tidy imports
"UP", # pyupgrade
"W", # pycodestyle warning
"YTT", # flake8-2020
]
ignore = [
"D100", # Missing docstring in public module
Expand All @@ -95,7 +102,6 @@ ignore = [
"N806", # non-lowercase-variable-in-function
"PD901", # pandas-df-variable-name
"PLC0414", # useless-import-alias
"PLC1901", # compare-to-empty-string
"PLR", # pylint refactor
"PT006", # pytest-parametrize-names-wrong-type
"PT013", # pytest-incorrect-pytest-import
Expand Down
1 change: 0 additions & 1 deletion tensorboard_reducer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from tensorboard_reducer.load import load_tb_events as load_tb_events
from tensorboard_reducer.main import main as main
from tensorboard_reducer.main import reduce_events as reduce_events
from tensorboard_reducer.reduce import reduce_events as reduce_events
from tensorboard_reducer.write import write_data_file as write_data_file
from tensorboard_reducer.write import write_df as write_df
Expand Down
5 changes: 4 additions & 1 deletion tensorboard_reducer/event_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@

import threading
from collections import namedtuple
from typing import TYPE_CHECKING

from tensorboard.backend.event_processing import (
directory_watcher,
event_file_loader,
io_wrapper,
reservoir,
)
from tensorboard.compat.proto.event_pb2 import Event

if TYPE_CHECKING:
from tensorboard.compat.proto.event_pb2 import Event

ScalarEvent = namedtuple("ScalarEvent", ["wall_time", "step", "value"])

Expand Down
2 changes: 1 addition & 1 deletion tensorboard_reducer/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def load_tb_events(
input_dirs: list[str],
strict_tags: bool = True,
strict_steps: bool = True,
handle_dup_steps: HandleDupSteps = None,
handle_dup_steps: HandleDupSteps | None = None,
min_runs_per_step: int | None = None,
verbose: bool = False,
) -> dict[str, pd.DataFrame]:
Expand Down
5 changes: 3 additions & 2 deletions tensorboard_reducer/reduce.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from typing import Sequence
from typing import TYPE_CHECKING, Sequence

import pandas as pd
if TYPE_CHECKING:
import pandas as pd


def reduce_events(
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from __future__ import annotations

from glob import glob
from typing import TYPE_CHECKING

import pandas as pd
import pytest

import tensorboard_reducer as tbr

if TYPE_CHECKING:
import pandas as pd

REDUCE_OPS = ("mean", "std", "median")


Expand Down
6 changes: 5 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import os
from glob import glob
from pathlib import Path
from typing import TYPE_CHECKING

import pytest
from pytest import CaptureFixture

from tensorboard_reducer import main

if TYPE_CHECKING:
from pathlib import Path


strict_runs = glob("tests/runs/strict/run_*")

lax_runs = glob("tests/runs/lax/run_*")
Expand Down
5 changes: 4 additions & 1 deletion tests/test_write.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
import ast
import itertools
import os
from pathlib import Path
from typing import TYPE_CHECKING

import pandas as pd
import pytest

import tensorboard_reducer as tbr
from tests.conftest import REDUCE_OPS

if TYPE_CHECKING:
from pathlib import Path


@pytest.mark.parametrize("verbose", [True, False])
def test_write_tb_events(
Expand Down

0 comments on commit ec3ecba

Please sign in to comment.