twisted / twisted/twisted

Introduce an API which can be used to define classes and methods which optionally require some third-party library

Open
#3,828 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

core enhancement new priority-high
Dominant language
Python
Stars
6k
Forks
1.2k
Avg merge
2d 10h
Merged PRs (30d)
10

Description

exarkun's avatar @exarkun reported
Trac ID trac#3828
Type enhancement
Created 2009-05-11 17:54:42Z

Twisted has a few external dependencies, generally (but not entirely) in the crypto department. Where Twisted implementation code meets these external dependencies, we try to fail gracefully. eg, you can use TCP without having pyOpenSSL installed; some of conch works without PyCrypto, etc.

The way this is done is ad hoc and so inconsistent. Sometimes the definition of a name will be skipped if a dependency of its implementation is absent. Sometimes multiple names are defined and one is conditionally selected to be "exported". Sometimes names are defined conditionally, with the off condition implementation raising an exception. Sometimes there is an interface which isn't declared if a dependency is missing.

On top of this, tests all have to handle this. They must try to figure out if some tests cannot succeed because of a missing dependency and then properly skip running the test. They do this in a variety of ways, most of which are quite error prone (hopefully we will have a buildslave to cover the missing dependencies case soon, but that will only make it easier to catch mistakes earlier).

We should examine our practices, determine their strengths and weaknesses, and codify the best of them somehow. Where possible, we should introduce helper APIs (most likely decorators, since those are the only obvious things which can be used to control the definition of other things - but we shouldn't necessarily restrict ourselves to decorators) to take out the redundancy and simplify testing.

Searchable metadata
trac-id__3828 3828
type__enhancement enhancement
reporter__exarkun exarkun
priority__high high
milestone__ 
branch__ 
branch_author__ 
status__new new
resolution__None None
component__core core
keywords__ 
time__1242064482000000 1242064482000000
changetime__1242114450000000 1242114450000000
version__None None
owner__ 
cc__z3p cc__glyph

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 examining Twisted's existing patterns for conditionally defining names and handling missing third-party dependencies, along with the tests that skip when dependencies are absent. Compare their strengths and weaknesses before designing a consistent helper API. Done means dependency-optional classes and methods, interfaces, and tests can follow a documented, less error-prone pattern.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.