Skip to content

Commit 76b189b

Browse files
authored
move stubs dir, fix hidden issues (#571)
bumped minimum ruamel-yaml version to 0.16.12 on py3.6 and 0.17.6 on py3.7+
1 parent 4eda814 commit 76b189b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+489
-846
lines changed

.github/workflows/ci-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ jobs:
9191
source .env/bin/activate && \
9292
python -m pip install --upgrade pip wheel setuptools_scm[toml] && \
9393
python -m pip install -r mypy-requirements.txt -r requirements.txt && \
94-
MYPYPATH=typeshed SCHEMA_SALAD_USE_MYPYC=1 python -m pip install -e .[pycodegen] && \
94+
MYPYPATH=mypy-stubs SCHEMA_SALAD_USE_MYPYC=1 python -m pip install -e .[pycodegen] && \
9595
deactivate'
9696
- name: Test with pytest
9797
run: |

.github/workflows/wheel-prep.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export SCHEMA_SALAD_USE_MYPYC=1
2-
export MYPYPATH=typeshed
2+
export MYPYPATH=mypy-stubs
33
export SETUPTOOLS_SCM_PRETEND_VERSION=$(grep __version__ schema_salad/_version.py | awk -F\' '{ print $2 }')

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
build/
77
dist/
8-
ruamel
9-
typeshed/ruamel/yaml
8+
mypy-stubs/ruamel/yaml
109
# virtualenv
1110
venv/
1211
.cache/

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ include schema_salad/tests/foreign/*.cwl
1212
recursive-include schema_salad/tests/test_real_cwl *
1313
include schema_salad/metaschema/*
1414
include schema_salad/tests/docimp/*
15-
recursive-include typeshed *.py?
15+
recursive-include mypy-stubs *.py?
1616
global-exclude *~
1717
global-exclude *.pyc

Makefile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ install-dep: install-dependencies
4949

5050
install-dependencies: FORCE
5151
pip install --upgrade $(DEVPKGS)
52-
pip install -r requirements.txt -r mypy-requirements.txt -r docs/requirements.txt
52+
pip install -r requirements.txt -r mypy-requirements.txt
5353

5454
## install : install the ${MODULE} module and script(s)
5555
install: FORCE
@@ -80,7 +80,7 @@ clean: FORCE
8080
# Linting and code style related targets
8181
## sorting imports using isort: https://github.com/timothycrosley/isort
8282
sort_imports: $(filter-out schema_salad/metaschema.py,$(PYSOURCES))
83-
isort $^ typeshed
83+
isort $^ mypy-stubs
8484

8585
remove_unused_imports: $(filter-out schema_salad/metaschema.py,$(PYSOURCES))
8686
autoflake --in-place --remove-all-unused-imports $^
@@ -98,10 +98,10 @@ diff_pydocstyle_report: pydocstyle_report.txt
9898

9999
## format : check/fix all code indentation and formatting (runs black)
100100
format:
101-
black --exclude metaschema.py --exclude _version.py schema_salad setup.py typeshed
101+
black --exclude metaschema.py --exclude _version.py schema_salad setup.py mypy-stubs
102102

103103
format-check:
104-
black --diff --check --exclude metaschema.py --exclude _version.py schema_salad setup.py typeshed
104+
black --diff --check --exclude metaschema.py --exclude _version.py schema_salad setup.py mypy-stubs
105105

106106
## pylint : run static code analysis on Python code
107107
pylint: $(PYSOURCES)
@@ -169,16 +169,10 @@ list-author-emails:
169169

170170
mypy3: mypy
171171
mypy: $(filter-out setup.py,$(PYSOURCES))
172-
if ! test -f $(shell python3 -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))')/py.typed ; \
173-
then \
174-
rm -Rf typeshed/ruamel/yaml ; \
175-
ln -s $(shell python3 -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))') \
176-
typeshed/ruamel/ ; \
177-
fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
178-
MYPYPATH=$$MYPYPATH:typeshed mypy $^
172+
MYPYPATH=$$MYPYPATH:mypy-stubs mypy $^
179173

180174
mypyc: $(PYSOURCES)
181-
MYPYPATH=typeshed SCHEMA_SALAD_USE_MYPYC=1 python setup.py test
175+
MYPYPATH=mypy-stubs SCHEMA_SALAD_USE_MYPYC=1 python setup.py test
182176

183177
pyupgrade: $(filter-out schema_salad/metaschema.py,$(PYSOURCES))
184178
pyupgrade --exit-zero-even-if-changed --py36-plus $^

docs/typeshed.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ How to add new types to the local Typeshed
33

44

55
If when running ``make mypy`` you receive errors about modules that can't be
6-
found you may need to add type stubs for new modules to the ``typeshed/``
6+
found you may need to add type stubs for new modules to the ``mypy-stubs/``
77
directory.
88

99
::
1010

11-
stubgen -o typeshed module_name
11+
stubgen -o mypy-stubs module_name
1212
make mypy
1313

1414
Note: the module name is not always the name of the PyPI package

typeshed/cachecontrol/__init__.pyi renamed to mypy-stubs/cachecontrol/__init__.pyi

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,4 @@ from typing import Any
66

77
from .wrapper import CacheControl as CacheControl
88

9-
# from .adapter import CacheControlAdapter as CacheControlAdapter
10-
# from .controller import CacheController as CacheController
11-
129
__email__ = ... # type: Any

mypy-stubs/cachecontrol/cache.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class BaseCache:
2+
def get(self, key: str) -> str | None: ...
3+
def set(self, key: str, value: str) -> None: ...
4+
def delete(self, key: str) -> None: ...
5+
def close(self) -> None: ...
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
from os import PathLike
2+
from typing import ContextManager
3+
4+
from ..cache import BaseCache as BaseCache
5+
from ..controller import CacheController as CacheController
6+
7+
class _LockClass:
8+
path: str
9+
10+
_lock_class = ContextManager[_LockClass]
11+
12+
class FileCache(BaseCache):
13+
directory: str | PathLike[str]
14+
forever: bool
15+
filemode: str
16+
dirmode: str
17+
lock_class: _lock_class
18+
def __init__(
19+
self,
20+
directory: str | PathLike[str],
21+
forever: bool = ...,
22+
filemode: int = ...,
23+
dirmode: int = ...,
24+
use_dir_lock: bool | None = ...,
25+
lock_class: _lock_class | None = ...,
26+
) -> None: ...
27+
@staticmethod
28+
def encode(x: str) -> str: ...
29+
def get(self, key: str) -> None | str: ...
30+
def set(self, key: str, value: str) -> None: ...
31+
def delete(self, key: str) -> None: ...

0 commit comments

Comments
 (0)