Skip to content

Commit 33efdfc

Browse files
authored
Merge pull request #204 from skogsbaer/sw/relative-imports
use relative imports
2 parents edec8c4 + dfb3bad commit 33efdfc

40 files changed

Lines changed: 167 additions & 176 deletions

python/.vscode/settings.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
11
{
2-
"python.analysis.diagnosticMode": "workspace",
3-
"python.analysis.diagnosticSeverityOverrides": {
4-
"reportWildcardImportFromLibrary": "none"
5-
},
6-
"python.analysis.extraPaths": [
7-
"/Users/swehr/.vscode/extensions/stefanwehr.write-your-python-program-2.0.7/python/code/"
8-
],
9-
"python.analysis.typeCheckingMode": "off"
2+
"python.analysis.diagnosticMode": "workspace"
103
}

python/code/wypp/__init__.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
try:
2-
from . import writeYourProgram as w
3-
except (ImportError, ModuleNotFoundError):
4-
import writeYourProgram as w
5-
1+
from dataclasses import dataclass
62
import typing
7-
83
# Exported names that are available for star imports (mostly in alphabetic order)
94
from typing import Any, Callable, Generator, Iterable, Iterator, Literal, Mapping, Optional, \
105
Protocol, Sequence, Union
11-
from dataclasses import dataclass
6+
7+
from . import writeYourProgram as w
128

139
check = w.check
1410
checkFail = w.checkFail

python/code/wypp/ansi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import os
12
import re
23
import sys
3-
import os
44

55
RESET = "\u001b[0;0m"
66
BOLD = "\u001b[1m"

python/code/wypp/cmdlineArgs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import argparse
22
import sys
3-
import utils
4-
from myLogging import *
3+
4+
from .myLogging import *
5+
from . import utils
56

67
def parseCmdlineArgs(argList):
78
parser = argparse.ArgumentParser(description='Run Your Program!',

python/code/wypp/debug.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
2-
import runner
2+
3+
from . import runner
34

45
# Use this file if you want to the some test file under the debugger
56
if __name__ == '__main__':

python/code/wypp/drawingLib.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import time
21
import threading
3-
import writeYourProgram as _w
2+
import time
43
from typing import Literal, Sequence
54

5+
from . import writeYourProgram as _w
6+
67
# Do not import tkinter at the top-level. Someone with no installation of tkinter should
78
# be able to user WYPP without drawing support.
89

python/code/wypp/errors.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
from __future__ import annotations
2-
from typing import *
32
import abc
43
import inspect
5-
import location
6-
import i18n
7-
from renderTy import renderTy
4+
from typing import *
5+
6+
from . import i18n
7+
from . import location
8+
from .renderTy import renderTy
89

910
class WyppError(abc.ABC):
1011
def __init__(self, extraFrames: list[inspect.FrameInfo] = []):

python/code/wypp/exceptionHandler.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1+
from dataclasses import dataclass
2+
import re
13
import sys
24
import traceback
3-
import re
4-
from dataclasses import dataclass
55

6-
# local imports
7-
from constants import *
8-
import stacktrace
9-
import paths
10-
from myLogging import *
11-
import errors
12-
import utils
6+
from .constants import *
7+
from . import errors
8+
from .myLogging import *
9+
from . import paths
10+
from . import stacktrace
11+
from . import utils
1312

1413
_tbPattern = re.compile(r'(\s*File\s+")([^"]+)(".*)')
1514
def _rewriteFilenameInTracebackLine(s: str) -> str:

python/code/wypp/i18n.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
from contextlib import contextmanager
12
from dataclasses import dataclass
2-
import location
33
from typing import *
4-
from contextlib import contextmanager
5-
import lang
6-
import utils
4+
5+
from . import lang
6+
from . import location
7+
from . import utils
78

89
type Lang = Literal['en', 'de']
910

python/code/wypp/instrument.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
from typing import *
2-
import os
31
import ast
2+
from collections.abc import Buffer
3+
from contextlib import contextmanager
44
import importlib
55
import importlib.abc
6-
from importlib.machinery import ModuleSpec, SourceFileLoader
76
import importlib.machinery
7+
from importlib.machinery import ModuleSpec, SourceFileLoader
88
from importlib.util import decode_source, spec_from_file_location
9-
from collections.abc import Buffer
10-
import types
9+
import os
1110
from os import PathLike
12-
import utils
13-
from myLogging import *
14-
from contextlib import contextmanager
15-
import errors
16-
import location
11+
import types
12+
from typing import *
13+
14+
from . import errors
15+
from . import location
16+
from .myLogging import *
17+
from . import utils
1718

1819
def parseExp(s: str) -> ast.expr:
1920
match ast.parse(s):

0 commit comments

Comments
 (0)