{"id":8098,"library":"django-filter-stubs","title":"django-filter-stubs","description":"django-filter-stubs provides PEP-484 compatible type stubs for the popular `django-filter` library, enabling static type checking with tools like Mypy. The project is currently at version 0.2.0, but it has been officially archived by its maintainers, meaning no further development, updates, or releases are expected.","status":"abandoned","version":"0.2.0","language":"en","source_language":"en","source_url":"https://github.com/DavisRayM/django-filter-stubs","tags":["django","mypy","type-stubs","typing"],"install":[{"cmd":"pip install django-filter-stubs","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Provides type stubs for this library.","package":"django-filter","optional":false},{"reason":"Implicit dependency for any Django project using django-filter.","package":"django","optional":false},{"reason":"Required for static type checking to utilize these stubs.","package":"mypy","optional":false}],"imports":[{"note":"Users do not directly import from `django_filter_stubs`. The package provides type definitions that Mypy automatically picks up when `django_filters` is imported.","symbol":"FilterSet","correct":"from django_filters import FilterSet"},{"note":"Similar to `FilterSet`, the stubs enhance type checking for imports from `django_filters.rest_framework`.","symbol":"DjangoFilterBackend","correct":"from django_filters.rest_framework import DjangoFilterBackend"}],"quickstart":{"code":"# mypy.ini or pyproject.toml\n\n# For mypy.ini:\n[mypy]\nplugins = mypy_django_plugin.main # If using django-stubs\n\n# For pyproject.toml:\n[tool.mypy]\nplugins = [\"mypy_django_plugin.main\"] # If using django-stubs\n\n# In your Django project's Python code:\n# This code would benefit from django-filter-stubs for type checking\nfrom django import forms\nfrom django_filters import FilterSet, CharFilter\nfrom django.db import models\n\nclass Product(models.Model):\n    name = models.CharField(max_length=255)\n    description = models.TextField()\n\n    class Meta:\n        app_label = 'myapp'\n\nclass ProductFilter(FilterSet):\n    name = CharFilter(field_name='name', lookup_expr='icontains')\n\n    class Meta:\n        model = Product\n        fields = ['name']\n\ndef get_filtered_products(request, queryset):\n    product_filter = ProductFilter(request.GET, queryset=queryset)\n    return product_filter.qs\n","lang":"python","description":"To use `django-filter-stubs`, simply install the package. Mypy will automatically discover and use the type stubs for `django-filter` and its submodules (like `django_filters.rest_framework`) during its static analysis pass. No explicit imports from `django_filter_stubs` are required. Ensure your Mypy configuration is set up correctly for Django projects, ideally using `django-stubs` if available, to handle Django's runtime 'magic'."},"warnings":[{"fix":"Consider migrating to `types-django-filter` (from typeshed, installed via `pip install types-django-filter`), which is actively maintained and provides current stubs for `django-filter`.","message":"The `django-filter-stubs` project has been officially archived by its maintainers. This means no further development, bug fixes, or compatibility updates are expected.","severity":"breaking","affected_versions":"0.2.0 and later"},{"fix":"Upgrade your Python environment to 3.8 or newer. Python 3.7 has reached its end-of-life.","message":"Version 0.2.0 of `django-filter-stubs` dropped support for Python 3.7. Attempting to use this version with Python 3.7 may lead to unexpected errors or missing type information.","severity":"breaking","affected_versions":"0.2.0"},{"fix":"If encountering type issues, manually inspect the `django-filter` source code or consider switching to the actively maintained `types-django-filter` package for up-to-date type definitions.","message":"Due to the project's archived status, the provided type stubs may become outdated quickly and might not accurately reflect the latest APIs or features of newer `django-filter` or Django versions. This can result in false positives or missed type errors in Mypy.","severity":"gotcha","affected_versions":"0.2.0 (all versions, due to lack of maintenance)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure `django-filter-stubs` (or `types-django-filter`) is installed: `pip install django-filter-stubs`. Verify your Mypy configuration correctly integrates with Django if using `django-stubs`.","cause":"Mypy cannot find type definitions for `django-filter` in your project, or the installed stubs are not being picked up correctly.","error":"error: Library 'django_filters' has no type annotations or does not export 'FilterSet' (or receives 'Any')"},{"fix":"Upgrade to a maintained stub package like `types-django-filter` (`pip install types-django-filter`). If the issue persists, the `types-django-filter` package might also be lagging behind the latest `django-filter` release. Consider adding `# type: ignore` comments temporarily or contributing to the `typeshed` project.","cause":"The installed `django-filter-stubs` version is likely outdated and does not include type definitions for newer attributes or methods introduced in a later version of `django-filter`.","error":"error: \"FilterSet\" has no attribute \"[some_attribute]\" [attr-defined]"},{"fix":"Remove `django-filter-stubs` and install `types-django-filter` instead. If using `django-stubs` for core Django types, ensure its version is compatible with your Mypy and Django versions. Run `mypy --no-incremental` to rule out caching issues.","cause":"An unmaintained stub package might have compatibility issues with newer versions of Mypy or Python interpreters, leading to crashes or incorrect type inference.","error":"Mypy crashes or reports unexpected errors during type checking after installing django-filter-stubs."}]}