flake8-mock-spec
A linter that checks mocks are constructed with the spec argument
Decision gist · record as of 2026-08-14
Yes, if you are already using flake8 and want to catch mock misuse in your test suite. The plugin is lightweight, has no complex dependencies, and solves a real problem. However, be aware that it is abandoned and will not receive updates or bug fixes—if you encounter issues with newer versions of flake8 or Python, you will need to maintain or fork it yourself.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction installation as a pure Python wheel with only flake8 as a runtime dependency.
- However, the package is abandoned—last release was 2023-01-14 with no updates since, so expect no maintenance or bug fixes going forward.
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions. No licensing friction for most projects.
last release 2023-01-14 (1308 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 127,524 downloads/mo, #11,739 on PyPI
Alternatives
Verify before relying
pip install flake8-mock-spec
# Then run flake8 on your test files:
flake8 test_source.py
# The plugin will warn on mocks without spec:
# test_source.py:5:22: TMS010 unittest.mock.Mock instances should be constructed with the spec or spec_set argument- Compatibility with flake8 versions released after 2023-01-14 is unverified given the package's abandoned status.
- Whether the plugin works correctly with modern unittest.mock patterns or async testing frameworks beyond what the description covers.
What it is and what it does
flake8-mock-spec is a linter plugin for flake8 that detects when unittest.mock objects (Mock, MagicMock, NonCallableMock, AsyncMock) are created without a spec or spec_set argument, and when patch operations lack spec-related arguments. It enforces a best practice: mocks should declare what interface they conform to, preventing tests from passing when they access methods or attributes that don't exist on the real object being mocked.
The plugin defines seven linting rules (TMS010–TMS013 for mock construction, TMS020–TMS022 for patch operations) that can be selectively suppressed. It integrates directly into your flake8 workflow with no additional configuration required beyond installation. However, the package has been abandoned since its single release in January 2023, meaning no updates or maintenance will occur.
Use it for
- Catch bugs in unit tests where mocks are called with methods that don't exist on the real object, preventing false test passes.
- Enforce team standards that all mocks must declare their spec to keep test code aligned with actual interfaces.
- Validate patch operations in test suites to ensure they include spec or autospec arguments for safer mocking.
- Integrate mock validation into CI/CD pipelines via flake8 to fail builds when mocks are created without spec constraints.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are already using flake8 and want to catch mock misuse in your test suite.
The plugin is lightweight, has no complex dependencies, and solves a real problem. However, be aware that it is abandoned and will not receive updates or bug fixes—if you encounter issues with newer versions of flake8 or Python, you will need to maintain or fork it yourself.
Install
flake8-mock-spec on PyPI
Before you install
Low friction installation as a pure Python wheel with only flake8 as a runtime dependency. However, the package is abandoned—last release was 2023-01-14 with no updates since, so expect no maintenance or bug fixes going forward.
License in practice
Licensed under Apache 2.0 (permissive), allowing free use, modification, and distribution with minimal restrictions. No licensing friction for most projects.
Quickstart
pip install flake8-mock-spec
# Then run flake8 on your test files:
flake8 test_source.py
# The plugin will warn on mocks without spec:
# test_source.py:5:22: TMS010 unittest.mock.Mock instances should be constructed with the spec or spec_set argument
Verify before relying
- Compatibility with flake8 versions released after 2023-01-14 is unverified given the package's abandoned status.
- Whether the plugin works correctly with modern unittest.mock patterns or async testing frameworks beyond what the description covers.
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.8.1,<4.0.0 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packageflake8 |
| Maintenance | Abandoned 1,308 days since the last release |
| First released | |
| Downloads | 127,524 / month, #11,739 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Environment :: ConsoleFramework :: Flake8Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseLicense :: Other/Proprietary LicenseProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Topic :: Software Development :: Libraries :: Python ModulesTopic :: Software Development :: Quality Assurance |
Evidence: flake8_mock_spec-1.4.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “flake8 mock linter”
- flake8-mock-specA flake8 plugin that enforces the use of the spec or spec_set…
- pyproject-flake8Enables flake8 linting to read configuration from pyproject.toml by…
- flake8-expression-complexityA flake8 extension that detects overly complex expressions in Python…
Give your agent the search over MCP, or paste the wish link into any chat.
More Python Modules packages
Converts domain names between Unicode and ASCII-compatible encoding (Punycode) according to IDNA 2008 and Unicode Technical Standard 46, with security validation and broader script coverage than the standard library.
Install it if you work with internationalized domain names, need to validate domains, or use HTTP clients that depend on it transitively.
Setuptools is a Python build backend and package management tool that handles building, distributing, and installing Python packages, including support for C/C++ extension modules.
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
Pydantic validates Python data structures against type hints, coercing and checking input at runtime to ensure it matches a declared schema.
Provides reusable metadata objects for use with PEP-593 `typing.Annotated` to express common constraints like bounds, collection sizes, and predicates on types.
Install it if you use or build libraries that need to express type constraints in a standardized, inspectable way—or if you want to annotate your own types with…
Provides runtime tools to inspect and introspect Python type annotations, enabling programmatic examination of type hints at execution time.
See also hacking · flake8 · mock · dlint · flexmock · flake8-annotations · flake8-formatter-junit-xml · callee · flake8-bandit · flake8-tidy-imports