Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions python/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
{
"python.analysis.diagnosticMode": "workspace",
"python.analysis.diagnosticSeverityOverrides": {
"reportWildcardImportFromLibrary": "none"
},
"python.analysis.extraPaths": [
"/Users/swehr/.vscode/extensions/stefanwehr.write-your-python-program-2.0.7/python/code/"
],
"python.analysis.typeCheckingMode": "off"
"python.analysis.diagnosticMode": "workspace"
}
10 changes: 3 additions & 7 deletions python/code/wypp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
try:
from . import writeYourProgram as w
except (ImportError, ModuleNotFoundError):
import writeYourProgram as w

from dataclasses import dataclass
import typing

# Exported names that are available for star imports (mostly in alphabetic order)
from typing import Any, Callable, Generator, Iterable, Iterator, Literal, Mapping, Optional, \
Protocol, Sequence, Union
from dataclasses import dataclass

from . import writeYourProgram as w

check = w.check
checkFail = w.checkFail
Expand Down
2 changes: 1 addition & 1 deletion python/code/wypp/ansi.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import re
import sys
import os

RESET = "\u001b[0;0m"
BOLD = "\u001b[1m"
Expand Down
5 changes: 3 additions & 2 deletions python/code/wypp/cmdlineArgs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import argparse
import sys
import utils
from myLogging import *

from .myLogging import *
from . import utils

def parseCmdlineArgs(argList):
parser = argparse.ArgumentParser(description='Run Your Program!',
Expand Down
3 changes: 2 additions & 1 deletion python/code/wypp/debug.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
import runner

from . import runner

# Use this file if you want to the some test file under the debugger
if __name__ == '__main__':
Expand Down
5 changes: 3 additions & 2 deletions python/code/wypp/drawingLib.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import time
import threading
import writeYourProgram as _w
import time
from typing import Literal, Sequence

from . import writeYourProgram as _w

# Do not import tkinter at the top-level. Someone with no installation of tkinter should
# be able to user WYPP without drawing support.

Expand Down
9 changes: 5 additions & 4 deletions python/code/wypp/errors.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from __future__ import annotations
from typing import *
import abc
import inspect
import location
import i18n
from renderTy import renderTy
from typing import *

from . import i18n
from . import location
from .renderTy import renderTy

class WyppError(abc.ABC):
def __init__(self, extraFrames: list[inspect.FrameInfo] = []):
Expand Down
17 changes: 8 additions & 9 deletions python/code/wypp/exceptionHandler.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
from dataclasses import dataclass
import re
import sys
import traceback
import re
from dataclasses import dataclass

# local imports
from constants import *
import stacktrace
import paths
from myLogging import *
import errors
import utils
from .constants import *
from . import errors
from .myLogging import *
from . import paths
from . import stacktrace
from . import utils

_tbPattern = re.compile(r'(\s*File\s+")([^"]+)(".*)')
def _rewriteFilenameInTracebackLine(s: str) -> str:
Expand Down
9 changes: 5 additions & 4 deletions python/code/wypp/i18n.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from contextlib import contextmanager
from dataclasses import dataclass
import location
from typing import *
from contextlib import contextmanager
import lang
import utils

from . import lang
from . import location
from . import utils

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

Expand Down
21 changes: 11 additions & 10 deletions python/code/wypp/instrument.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
from typing import *
import os
import ast
from collections.abc import Buffer
from contextlib import contextmanager
import importlib
import importlib.abc
from importlib.machinery import ModuleSpec, SourceFileLoader
import importlib.machinery
from importlib.machinery import ModuleSpec, SourceFileLoader
from importlib.util import decode_source, spec_from_file_location
from collections.abc import Buffer
import types
import os
from os import PathLike
import utils
from myLogging import *
from contextlib import contextmanager
import errors
import location
import types
from typing import *

from . import errors
from . import location
from .myLogging import *
from . import utils

def parseExp(s: str) -> ast.expr:
match ast.parse(s):
Expand Down
11 changes: 5 additions & 6 deletions python/code/wypp/interactive.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@

import sys
import os
import code
from dataclasses import dataclass
import os
import sys

# local imports
from constants import *
from myLogging import *
from exceptionHandler import handleCurrentException
from .constants import *
from .exceptionHandler import handleCurrentException
from .myLogging import *

HISTORY_SIZE = 1000

Expand Down
4 changes: 2 additions & 2 deletions python/code/wypp/lang.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import locale
from _collections_abc import MutableMapping
import locale
import os

def _langFromEnv(env: MutableMapping) -> str | None:
# 1) GNU LANGUAGE: colon-separated fallbacks (e.g., "de:en_US:en")
Expand Down
23 changes: 12 additions & 11 deletions python/code/wypp/location.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
from __future__ import annotations
from typing import *
import abc
import ast
from dataclasses import dataclass
import dis
import inspect
import linecache
import dis
import ast
import ansi
import utils
import myLogging
import os
import sys
import abc
import parsecache
from parsecache import FunMatcher
import paths
import tokenize
import os
from typing import *

from . import ansi
from . import myLogging
from . import parsecache
from .parsecache import FunMatcher
from . import paths
from . import utils

@dataclass
class EncodedBytes:
Expand Down
3 changes: 2 additions & 1 deletion python/code/wypp/myLogging.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import utils
import sys

from . import utils

VERBOSE = False # set via commandline
DEBUG = utils.getEnv("WYPP_DEBUG", bool, False)

Expand Down
8 changes: 4 additions & 4 deletions python/code/wypp/myTypeguard.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Wrapper module for typeguard. Do not import typeguard directly but always via myTypeguard
from __future__ import annotations
from typing import *
from dataclasses import dataclass
from myLogging import *

# We externally adjust the PYTHONPATH so that the typeguard module can be resolved
import typeguard # type: ignore
import typeguard # type: ignore
from typing import *

from .myLogging import *

@dataclass(frozen=True)
class Namespaces:
Expand Down
4 changes: 2 additions & 2 deletions python/code/wypp/parsecache.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ast
import os
import linecache
from dataclasses import dataclass
import linecache
import os
from typing import *

def _firstLineOfFun(node: ast.FunctionDef | ast.AsyncFunctionDef) -> int:
Expand Down
2 changes: 1 addition & 1 deletion python/code/wypp/paths.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from contextlib import contextmanager
import os
from typing import *
from contextlib import contextmanager

_projectDir: Optional[str] = None

Expand Down
17 changes: 9 additions & 8 deletions python/code/wypp/records.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import typing
import dataclasses
import utils
import sys
import myTypeguard
import errors
import typecheck
import location
import stacktrace
from utils import _call_with_frames_removed
import typing

from . import errors
from . import location
from . import myTypeguard
from . import stacktrace
from . import typecheck
from . import utils
from .utils import _call_with_frames_removed

EQ_ATTRS_ATTR = '__eqAttrs__'

Expand Down
3 changes: 2 additions & 1 deletion python/code/wypp/renderTy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import collections.abc
import types
from typing import *
import myTypeguard

from . import myTypeguard
#def renderTy(t: Any) -> str:
# if isinstance(t, str):
# return t
Expand Down
9 changes: 5 additions & 4 deletions python/code/wypp/replTester.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import sys
import doctest
from contextlib import contextmanager
import ansi
from myLogging import *
import doctest
import sys

from . import ansi
from .myLogging import *

# We use our own DocTestParser to replace exception names in stacktraces

Expand Down
27 changes: 11 additions & 16 deletions python/code/wypp/runCode.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import sys
import os
from contextlib import contextmanager
from dataclasses import dataclass
import importlib
import os
import runpy
from dataclasses import dataclass
import sys
from typing import Optional
from contextlib import contextmanager

# local imports
from constants import *
import stacktrace
import instrument
from myLogging import *
from exceptionHandler import handleCurrentException
import utils
from .constants import *
from .exceptionHandler import handleCurrentException
from . import instrument
from .myLogging import *
from . import stacktrace
from . import utils

class Lib:
def __init__(self, mod, properlyImported):
Expand Down Expand Up @@ -87,11 +86,7 @@ def debugModule(name):
print("Origin:", spec.origin)
print("Loader:", type(spec.loader).__name__)

import sys
import os
import contextlib

@contextlib.contextmanager
@contextmanager
def freshModules():
original_modules = sys.modules.copy()
stdlib_path = os.path.dirname(os.__file__)
Expand Down
2 changes: 1 addition & 1 deletion python/code/wypp/runYourProgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
sys.exit(1)

if __name__ == '__main__':
import runner as r
import wypp.runner as r
r.main(globals())
Loading
Loading