import os
from typing import List

from setuptools import find_packages, setup


def find_stub_files(name: str) -> List[str]:
    result = []
    for root, _dirs, files in os.walk(name):
        for file in files:
            if file.endswith(".pyi"):
                if os.path.sep in root:
                    sub_root = root.split(os.path.sep, 1)[-1]
                    file = os.path.join(sub_root, file)
                result.append(file)
    return result


with open("README.md") as f:
    readme = f.read()

dependencies = [
    "mypy>=0.980",
    "django",
    "django-stubs-ext>=0.7.0",
    "tomli",
    # Types:
    "typing-extensions",
    "types-pytz",
    "types-PyYAML",
]

extras_require = {
    "compatible-mypy": ["mypy>=0.980,<0.990"],
}

setup(
    name="django-stubs",
    version="1.13.1",
    description="Mypy stubs for Django",
    long_description=readme,
    long_description_content_type="text/markdown",
    license="MIT",
    url="https://github.com/typeddjango/django-stubs",
    author="Maksim Kurnikov",
    author_email="maxim.kurnikov@gmail.com",
    maintainer="Nikita Sobolev",
    maintainer_email="mail@sobolevn.me",
    py_modules=[],
    python_requires=">=3.7",
    install_requires=dependencies,
    extras_require=extras_require,
    packages=["django-stubs", *find_packages(exclude=["scripts"])],
    package_data={
        "django-stubs": find_stub_files("django-stubs"),
        "mypy_django_plugin": ["py.typed"],
    },
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Typing :: Typed",
        "Framework :: Django",
        "Framework :: Django :: 2.2",
        "Framework :: Django :: 3.0",
        "Framework :: Django :: 3.1",
        "Framework :: Django :: 3.2",
        "Framework :: Django :: 4.0",
        "Framework :: Django :: 4.1",
    ],
    project_urls={
        "Release notes": "https://github.com/typeddjango/django-stubs/releases",
    },
)

setup.py
import os
from typing import List

from setuptools import find_packages, setup


def find_stub_files(name: str) -> List[str]:
    result = []
    for root, _dirs, files in os.walk(name):
        for file in files:
            if file.endswith(".pyi"):
                if os.path.sep in root:
                    sub_root = root.split(os.path.sep, 1)[-1]
                    file = os.path.join(sub_root, file)
                result.append(file)
    return result


with open("README.md") as f:
    readme = f.read()

dependencies = [
    "mypy>=0.980",
    "django",
    "django-stubs-ext>=0.7.0",
    "tomli",
    # Types:
    "typing-extensions",
    "types-pytz",
    "types-PyYAML",
]

extras_require = {
    "compatible-mypy": ["mypy>=0.980,<0.990"],
}

setup(
    name="django-stubs",
    version="1.13.2",
    description="Mypy stubs for Django",
    long_description=readme,
    long_description_content_type="text/markdown",
    license="MIT",
    url="https://github.com/typeddjango/django-stubs",
    author="Maksim Kurnikov",
    author_email="maxim.kurnikov@gmail.com",
    maintainer="Nikita Sobolev",
    maintainer_email="mail@sobolevn.me",
    py_modules=[],
    python_requires=">=3.7",
    install_requires=dependencies,
    extras_require=extras_require,
    packages=["django-stubs", *find_packages(exclude=["scripts"])],
    package_data={
        "django-stubs": find_stub_files("django-stubs"),
        "mypy_django_plugin": ["py.typed"],
    },
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Programming Language :: Python :: 3.10",
        "Programming Language :: Python :: 3.11",
        "Typing :: Typed",
        "Framework :: Django",
        "Framework :: Django :: 2.2",
        "Framework :: Django :: 3.0",
        "Framework :: Django :: 3.1",
        "Framework :: Django :: 3.2",
        "Framework :: Django :: 4.0",
        "Framework :: Django :: 4.1",
    ],
    project_urls={
        "Release notes": "https://github.com/typeddjango/django-stubs/releases",
    },
)

setup.py
diff --git a/setup.py b/setup.py
index 442eeed98..6649dac60 100644
--- a/setup.py
+++ b/setup.py
@@ -36,7 +36,7 @@ def find_stub_files(name: str) -> List[str]:
 
 setup(
     name="django-stubs",
-    version="1.13.1",
+    version="1.13.2",
     description="Mypy stubs for Django",
     long_description=readme,
     long_description_content_type="text/markdown",

Next release planning (1.13.2)
I'd like to make a new django-stubs release soonish.

I think this is a blocker: 
* #1311 

~~I don't know how to unlock mypy 0.991 support other than to disable testing with Django 3.2 and 2.2 (due to #1261). That's not ideal, but it is a step towards the new versioning policy we discussed in https://github.com/typeddjango/django-stubs/issues/1095#issuecomment-1307066177 to only support the latest Django version.~~
* #1260

Nice to have PRs:
* #1309
* #1308
* #1315

Would this be version 1.13.2, 1.14.0 or go with https://github.com/typeddjango/django-stubs/issues/1095#issuecomment-1307066177 and call it 4.1.0?

@sobolevn @adamchainz feedback welcome (and anyone else)

