Skip to content

remove cache options #158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pandas-stubs/_typing.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ from typing import (
)

import numpy as np
from numpy import typing as npt
import numpy.typing
from pandas.core.arrays import ExtensionArray
from pandas.core.frame import DataFrame
from pandas.core.generic import NDFrame
Expand All @@ -42,6 +42,8 @@ from pandas._libs.tslibs import (

from pandas.core.dtypes.dtypes import ExtensionDtype

npt = numpy.typing

ArrayLike = Union[ExtensionArray, np.ndarray]
AnyArrayLike = Union[Index, Series, np.ndarray]
PythonScalar = Union[str, int, float, bool, complex]
Expand Down
33 changes: 6 additions & 27 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ python = ">=3.8,<3.11"
types-pytz = ">= 2022.1.1"

[tool.poetry.dev-dependencies]
mypy = ">=0.961"
mypy = ">=0.971"
pytest = ">=7.1.2"
pyright = ">=1.1.255"
poethepoet = ">=0.13.1"
Expand All @@ -53,36 +53,15 @@ build-backend = "poetry.core.masonry.api"

[tool.poe.tasks.test_all]
help = "Run all tests"
script = "scripts.test:test(clean_cache, src=True, dist=True)"

[[tool.poe.tasks.test_all.args]]
help = "remove cache folders (mypy and pytest)"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false
type = "boolean"
script = "scripts.test:test(src=True, dist=True)"

[tool.poe.tasks.test_src]
help = "Run local tests (includes 'mypy_src', 'pyright_src', 'pytest', and 'style')"
script = "scripts.test:test(clean_cache, src=True)"

[[tool.poe.tasks.test_src.args]]
help = "remove cache folders (mypy and pytest)"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false
type = "boolean"
script = "scripts.test:test(src=True)"

[tool.poe.tasks.test_dist]
help = "Run tests on the installed stubs (includes 'mypy_dist' and 'pyright_dist')"
script = "scripts.test:test(clean_cache, dist=True)"

[[tool.poe.tasks.test_dist.args]]
help = "remove cache folders (mypy and pytest)"
name = "clean-cache"
options = ["-c", "--clean_cache"]
default = false
type = "boolean"
script = "scripts.test:test(dist=True)"

[tool.poe.tasks.pytest]
help = "Run pytest"
Expand All @@ -98,15 +77,15 @@ script = "scripts.test.run:mypy_src"

[tool.poe.tasks.mypy_dist]
help = "Run mypy on 'tests' using the installed stubs"
script = "scripts.test:test(clean_cache=False, dist=True, type_checker='mypy')"
script = "scripts.test:test(dist=True, type_checker='mypy')"

[tool.poe.tasks.pyright_src]
help = "Run pyright on 'tests' (using the local stubs) and on the local stubs"
script = "scripts.test.run:pyright_src"

[tool.poe.tasks.pyright_dist]
help = "Run pyright on 'tests' using the installed stubs"
script = "scripts.test:test(clean_cache=False, dist=True, type_checker='pyright')"
script = "scripts.test:test(dist=True, type_checker='pyright')"



Expand Down
5 changes: 0 additions & 5 deletions scripts/test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from scripts._job import run_job
from scripts.test import _step

_CACHE_STEPS = [_step.clean_mypy_cache, _step.clean_pytest_cache]
_SRC_STEPS = [_step.mypy_src, _step.pyright_src, _step.pytest, _step.style]
_DIST_STEPS = [
_step.build_dist,
Expand All @@ -17,15 +16,11 @@


def test(
clean_cache: bool = False,
src: bool = False,
dist: bool = False,
type_checker: Literal["", "mypy", "pyright"] = "",
):
steps = []
if clean_cache:
steps.extend(_CACHE_STEPS)

if src:
steps.extend(_SRC_STEPS)

Expand Down
2 changes: 0 additions & 2 deletions scripts/test/_step.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from scripts._job import Step
from scripts.test import run

clean_mypy_cache = Step(name="Clean mypy cache", run=run.clean_mypy_cache)
clean_pytest_cache = Step(name="Clean pytest cache", run=run.clean_pytest_cache)
mypy_src = Step(
name="Run mypy on 'tests' (using the local stubs) and on the local stubs",
run=run.mypy_src,
Expand Down
13 changes: 1 addition & 12 deletions scripts/test/run.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from pathlib import Path
import shutil
import subprocess


Expand All @@ -14,7 +13,7 @@ def pyright_src():


def pytest():
cmd = ["pytest"]
cmd = ["pytest", "--cache-clear"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

double checking that not clearing the cache will always work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Locally, I do not need to clear the cache. Happy to remove it. The CI will anyways have a clean plate every time it runs.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I see. Now your proposal is to always clear the cache. I think that's a good idea. Equivalent to what will happen with mypy where we always use --no-incremental

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with keeping the pytest cache - just wanted to match the behavior of mypy.

subprocess.run(cmd, check=True)


Expand Down Expand Up @@ -61,13 +60,3 @@ def restore_src():
Path(r"_pandas-stubs").rename("pandas-stubs")
else:
raise FileNotFoundError("'_pandas-stubs' folder does not exists.")


def clean_mypy_cache():
if Path(".mypy_cache").exists():
shutil.rmtree(".mypy_cache")


def clean_pytest_cache():
if Path(".mypy_cache").exists():
shutil.rmtree(".pytest_cache")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test was wrong here, so the -c never worked!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hahaha :) I didn't notice that when I removed it :)