Skip to content

Commit e0f1e32

Browse files
authored
Add type annotations to UPath (#79)
* pyproject.toml: add mypy config * upath: add type annotations and switch to urlsplit/urlunsplit * upath: fix self._url = None issue in relative_to * upath: add py.typed file * upath: linting and formatting * ci: check typing in ci * upath: add comment regarding UPath.touch
1 parent d6f0410 commit e0f1e32

File tree

7 files changed

+189
-84
lines changed

7 files changed

+189
-84
lines changed

.github/workflows/python.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,12 @@ on:
33
push:
44
pull_request:
55
jobs:
6-
build:
6+
tests:
77
runs-on: ${{ matrix.os }}
88
strategy:
99
matrix:
1010
python-version: [3.7, 3.8, 3.9, "3.10", "3.11-dev"]
1111
os: [ubuntu-latest, windows-latest]
12-
1312
steps:
1413
- uses: actions/checkout@v3
1514
- name: Set up Python ${{ matrix.python-version }}
@@ -23,9 +22,33 @@ jobs:
2322
- name: Test with pytest
2423
run: |
2524
nox -s smoke
25+
26+
lint:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Set up Python ${{ matrix.python-version }}
31+
uses: actions/setup-python@v4
32+
- name: Install dependencies
33+
run: |
34+
python -m pip install --upgrade pip nox
2635
- name: Lint
2736
run: |
2837
nox -s lint
38+
- name: Type Checking
39+
run: |
40+
nox -s type_checking
41+
42+
build:
43+
needs: [tests, lint]
44+
runs-on: ubuntu-latest
45+
steps:
46+
- uses: actions/checkout@v3
47+
- name: Set up Python ${{ matrix.python-version }}
48+
uses: actions/setup-python@v4
49+
- name: Install dependencies
50+
run: |
51+
python -m pip install --upgrade pip nox
2952
- name: build package
3053
run: |
3154
nox -s build

noxfile.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ def lint(session):
2222
session.run("flake8", "upath")
2323

2424

25+
@nox.session()
26+
def type_checking(session):
27+
session.install("mypy")
28+
session.run("mypy", "upath")
29+
30+
2531
@nox.session()
2632
def install(session):
2733
session.install(".")
@@ -31,9 +37,12 @@ def install(session):
3137
def smoke(session):
3238
if (3, 10) < sys.version_info <= (3, 11, 0, "final"):
3339
# workaround for missing aiohttp wheels for py3.11
34-
session.install("aiohttp", "--no-binary", "aiohttp", env={
35-
"AIOHTTP_NO_EXTENSIONS": "1"
36-
})
40+
session.install(
41+
"aiohttp",
42+
"--no-binary",
43+
"aiohttp",
44+
env={"AIOHTTP_NO_EXTENSIONS": "1"},
45+
)
3746

3847
session.install(
3948
"pytest",

pyproject.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,21 @@ include = []
5151
[tool.black]
5252
line-length = 80
5353
target-version = ['py38']
54+
55+
[tool.mypy]
56+
python_version = "3.7"
57+
warn_return_any = true
58+
warn_unused_configs = true
59+
exclude = "^notebooks|^venv.*|tests.*|^noxfile.py"
60+
61+
[[tool.mypy.overrides]]
62+
module = "fsspec.*"
63+
ignore_missing_imports = true
64+
65+
[[tool.mypy.overrides]]
66+
module = "webdav4.fsspec.*"
67+
ignore_missing_imports = true
68+
69+
[[tool.mypy.overrides]]
70+
module = "setuptools.*"
71+
ignore_missing_imports = true

0 commit comments

Comments
 (0)