Skip to content

Commit 078f840

Browse files
authored
Merge pull request #16 from ericdill/fix-circular-import
Fix circular import while preserving backwards compatibility
2 parents aabbe30 + 274f11f commit 078f840

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

stdlib_list/__init__.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,4 @@
11
from ._version import __version__
22

3-
4-
import os
5-
6-
base_dir = os.path.dirname(os.path.realpath(__file__))
7-
list_dir = os.path.join(base_dir, "lists")
8-
9-
long_versions = ["2.6.9", "2.7.9", "3.2.6", "3.3.6", "3.4.3", "3.5", "3.6"]
10-
11-
short_versions = [".".join(x.split(".")[:2]) for x in long_versions]
12-
13-
14-
def get_canonical_version(version):
15-
16-
if version in long_versions:
17-
version = ".".join(version.split(".")[:2])
18-
elif version not in short_versions:
19-
raise ValueError("No such version: {}".format(version))
20-
21-
return version
22-
23-
24-
from .base import stdlib_list
3+
# Import all the things that used to be in here for backwards-compatibility reasons
4+
from .base import stdlib_list, get_canonical_version, short_versions, long_versions, base_dir, list_dir

stdlib_list/base.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,23 @@
33
import os
44
import sys
55

6-
from . import get_canonical_version, list_dir
6+
base_dir = os.path.dirname(os.path.realpath(__file__))
7+
8+
list_dir = os.path.join(base_dir, "lists")
9+
10+
long_versions = ["2.6.9", "2.7.9", "3.2.6", "3.3.6", "3.4.3", "3.5", "3.6"]
11+
12+
short_versions = [".".join(x.split(".")[:2]) for x in long_versions]
13+
14+
15+
def get_canonical_version(version):
16+
17+
if version in long_versions:
18+
version = ".".join(version.split(".")[:2])
19+
elif version not in short_versions:
20+
raise ValueError("No such version: {}".format(version))
21+
22+
return version
723

824

925
def stdlib_list(version=None):

0 commit comments

Comments
 (0)