Frameworks¶
What a framework finds and calls by itself counts as used, such as pytest's tests or Django's settings. A framework is turned off in the configuration:
[tool.unref.frameworks]
unittest = false
pytest¶
Enabled by default: yes.
- In
test_*.pyand*_test.pyfiles:test*functions,Test*classes and theirtest*methods, setup and teardown functions. - Anywhere:
pytest_*hooks and fixtures.
A project that sets python_files, python_classes or python_functions adds its own names with an
override:
[[tool.unref.overrides]]
paths = ["tests"]
used-names = ["check_*", "Describe*"]
unittest¶
Enabled by default: yes.
- Subclasses of
unittest.TestCase, with theirtest*,setUpandtearDownmethods.
pydantic¶
Enabled by default: yes.
- In subclasses of
pydantic.BaseModel: fields andmodel_config. - Anywhere: methods with Pydantic's validator and serializer decorators and
computed_field, also when applied by hand, as in_check = field_validator("name")(check).
dataclasses¶
Enabled by default: yes.
- Fields of classes with
dataclasses.dataclass, Pydantic'sdataclassor an attrs decorator such asattrs.define. - Fields of
NamedTuplesubclasses.
sqlalchemy¶
Enabled by default: yes.
- In declarative models and their mixins: attributes annotated
Mapped, or set tomapped_column,Column,relationshipand the like. - Anywhere: functions with
event.listens_for,validates,reconstructorordeclared_attr.
fastapi¶
Enabled by default: yes.
- Functions and methods with a route or event decorator, such as
app.getorrouter.websocket, of aFastAPI()orAPIRouter(), or an instance of a subclass, set at module level or in the same function.
flask¶
Enabled by default: yes.
- Functions and methods with a route, error or request decorator, such as
app.routeorbp.errorhandler, ofFlask()orBlueprint(), or an instance of a subclass, set at module level or in the same function, of a parameter annotated as one, of a parameter of a test or fixture named as a pytest fixture that returns or yields one, of a module-level variable set to what a factory makes, or ofcurrent_app. - Commands of
cli.commandandcli.groupof these, and ofcommandandgroupof anAppGroup()or of such a group. - Module-level
create_appandmake_appfunctions that make aFlask(), and module-levelappandapplicationvariables set toFlask()or to what such a factory makes. - HTTP method handlers of
MethodViewsubclasses,dispatch_requestofViewsubclasses, and their class attributesmethods,provide_automatic_options,decoratorsandinit_every_request. - Functions decorated with
after_this_request, and receivers thatconnectandconnect_viaof Flask's signals, such asrequest_started, connect. Notcopy_current_request_contextorstream_with_context, which only wrap a function.
flask-restful¶
Enabled by default: yes. Covers Flask-RESTful and Flask-RESTX.
- HTTP method handlers of
Resourcesubclasses, and theirmethod_decoratorsand the class attributes thatflaskreads of a view. With the package installed in the environment, theflaskrules find them as aMethodViewas well. - Classes with the
resourcedecorator of anApiof Flask-RESTful, or theroutedecorator of anApior aNamespaceof Flask-RESTX. - Functions with the
representationdecorator of anApi, or theerrorhandlerdecorator of anApior aNamespaceof Flask-RESTX, or itsdocumentationdecorator of anApi. - The instances are set at module level or in the same function, or a parameter annotated as one, and
a
Namespacecan be a module-level variable set to whatapi.namespace()makes.
sphinx¶
Enabled by default: yes.
- In Sphinx's configuration files: module-level variables not starting with
_, and thesetupandlinkcode_resolvefunctions.
The configuration files are each conf.py that sets project, extensions or html_theme, or those that
configuration names. A table turns the rules on:
[tool.unref.frameworks.sphinx]
configuration = ["docs/conf.py"]
django¶
Enabled by default: yes.
- In settings modules: module-level uppercase names, such as
DEBUG. - In the module that
ROOT_URLCONFnames:urlpatternsandhandler400,handler403,handler404,handler500. - In modules that
include("...")names:urlpatternsandapp_name. - Module-level variables set to
get_wsgi_application()orget_asgi_application(). - Subclasses of
AppConfig, with theirreadymethod and attributes such asname. - Subclasses of
MigrationnamedMigration, with their attributes such asoperationsanddependencies. - In models: fields, such as
models.CharField(...)orForeignKey(...), the first manager, theMetaclass with its options, andget_absolute_url. In managers:get_queryset. - In forms: fields,
clean_<field>methods, theMediaclass, and theMetaclass of aModelForm. TheMediaclass of widgets and of the admin's classes, such asModelAdmin. - In class-based views, subclasses of
View: methods named by HTTP methods, such asgetandpost. - Classes named
Commandin modules ofmanagement/commandswhose name does not start with_, and in subclasses ofBaseCommand:handle,add_argumentsand attributes such ashelp. - Template tags and filters of
register.filter,register.simple_tagand the like, of a module-levelLibrary(), and a module-levelregistervariable set to one. - Functions with
receiver. - In filter sets of
django-filter: filters, such asdjango_filters.CharFilter(...), and theMetaclass with its options.
The settings modules are those that os.environ.setdefault("DJANGO_SETTINGS_MODULE", ...) names, those
that settings names, and the modules they star import. A table turns the rules on:
[tool.unref.frameworks.django]
settings = ["config/settings/production.py"]
rest-framework¶
Enabled by default: yes.
- In serializers: fields, such as
serializers.CharField(...)or a nested serializer,validate_<field>methods, theget_<field>method of aSerializerMethodField, and theMetaclass with its options. - In views, subclasses of
APIViewand the generic views and viewsets: methods named by HTTP methods, such asget, and the attributes that configure them, such asserializer_class,permission_classesandfilterset_class. - In viewsets: the actions
list,create,retrieve,update,partial_updateanddestroy. - Anywhere: methods with
action.
celery¶
Enabled by default: yes.
- Tasks of
shared_task, and of thetaskdecorator ofCelery(), or an instance of a subclass, set at module level or in the same function, of a parameter annotated as one, or ofcurrent_app. - In subclasses of
Task:runand handlers such ason_failure.
click¶
Enabled by default: yes.
- Commands and groups of the
commandandgroupdecorators of a group, and functions of itsresult_callbackdecorator. A group is aGroup(), or an instance of a subclass, set at module level or in the same function, or a function thatclick.groupor thegroupdecorator of a group makes into one. The same holds for rich-click and asyncclick.
A function that only click.command or click.group makes into a command is registered nowhere, so it
counts as used only if something refers to it, such as an entry point or add_command.
typer¶
Enabled by default: yes.
- Functions of the
commandandcallbackdecorators of aTyper(), or an instance of a subclass, set at module level or in the same function.