python / python/typeshed

'array.array' has no attribute 'clear'

Open
#11,008 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

stubs: false negative
Dominant language
Python
Stars
5.1k
Forks
2.1k
Avg merge
1d 19h
Merged PRs (30d)
82

Description

array.array inheriting from MutableSequence has some unintended consequences, such as below

import array

x = array.array("B")
x.clear()

At runtime array.array does not have .clear(). Is it meant to have a .clear() implemented? Right now at least it doesn't and the stubs give an incorrect definition.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the typeshed stub for array.array and compare its inherited MutableSequence methods with the runtime behavior shown in the issue. Check whether array.array is expected to provide clear(); done means the stub accurately reflects the runtime, with the issue's question about adding the method resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.