Code Monkey home page Code Monkey logo

scarletio's Introduction

Huyane Matsu

New innovative programming disciplines, frameworks and products, I create new code.



I am a professional Python developer.

scarletio's People

Contributors

albertopoljak avatar huyanematsu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

albertopoljak

scarletio's Issues

IC auto completion

The interactive console should auto complete variable names when tab is pressed.

RFC: Code styling

Warning

You're gonna hate this issue ๐Ÿ…ฐ๏ธ

Introduction

Scarletio (and Hata) use an unorthodox code style that may be intimidating to contributors and users. I've decided to make this issue in an attempt to create a code styling convention that would be enforced throughout this codebase. A cleaner styling convention would increase readability and maintainability tenfold. I am willing refactor the codebase to implement a new coding style.

Imports

I propose that imports be sorted alphabetically, this can be done automatically by tools like isort.

Line Continuations

Scarletio uses line continuations to break imports into multiple lines. I propose that all occurrences of line continuations be replaced by parenthesis.

Example:

from a import a, b, \
    c, d, e, f, g

becomes

from a import (
    a, b, c, d, e, f, g
)

Whitespace

Scarletio uses lots of unnecessary whitespace on blank lines and in-between function definitions in classes. In other areas is doesn't use enough whitespace. I propose that a flake8 compatible whitespace convention be adopted.
Note: This would also entail removing unnecessary indents from blank lines.

Example:

from math import log

MAGIC_NUMBER = 0x5f3759df
    
class Mathematician:
    def __init__(self, name):
        self.name = name
    
    
    def q_sqrt(self, x):
        # Definitely a real working Q_sqrt implementation.
        return MAGIC_NUMBER-(x>>1)

becomes

from math import log

MAGIC_NUMBER = 0x5f3759df


class Mathematician:
    def __init__(self, name):
        self.name = name

    def q_sqrt(self, x):
        # Definitely a real working Q_sqrt implementation.
        return MAGIC_NUMBER - (x >> 1)

Parenthesis

Scarletio uses some unnecessary parenthesis in if statements. I propose that these unnecessary parenthesis be removed and that the end of multiline parenthesis be moved to match the indentation level.

Example:

if (not isinstance(x, ABC)) or (not isinstance(y, XYZ)):
    raise TypeError('received invalid x'
        'or invalid y')

becomes

if not isinstance(x, ABC) or not isinstance(y, XYZ):
    raise TypeError(
        'received invalid x or invalid y'
    )

Stdlib (not really style)

Scarletio reimplements some things that already exists in stdlib. I propose that such modules be deleted and that the stdlib modules be used instead.

Example:

print(code.CO_OPTIMIZED)
assert async_utils.is_coroutine_funciton(x)
print(utils.relative_index(y))

becomes

import inspect
import bisect

print(inspect.CO_OPTIMIZED)
assert inspect.iscoroutinefunction(x)
print(bisect.bisect(y))

Async debug

Scarletio should have an option to turn on async debug mode.

Async debug mode would trace every future mutation. If required these actions could be displayed. By default these would be shown if a future is not completed as expected.

The feature can implemented on two ways:

  • Environmental variable that sets debug mode on startup.
  • Functional api that modifies the future api runtime.

This change would also require trace handling modifications, since it needs to store the trace. Long-time trace storing would require to ditch the frame itself to enable garbage collection.

Interactive console server

There should be a way to host a server from the current process, that allows other processes to connect into it with an interactive console.

This would greatly improve debugging in case the execution context does not provide a way to run an interactive console on itself. (This is true when using containers.)

Additionally would help with collaboration, so multiple people can work on a single instance.

The server should run the code inputted by the client consoles.
The server stdout / stderr should be distributed between the clients.
The execution output should be returned to the clients as string / trace, so other consoles would not show that.

Allow exception to have multiple causes

Some exceptions might have multiple cause, but no builtin solution can resolve it.

Proposal:

raise Exception from CauseGroup(...)

The traceback renderer should pick up CauseGroup as a special case and render the cause accordingly.

Improved Frame handling for tracing

Frame representations should be rewritten, so we can un-allocate the frames, but keep the trace.
This would be useful to reserve traces of exceptions / tasks in case we want to render the trace later / elsewhere.

This is required for:

  • Async debug.
  • Postponing trace-back styling (vampytest module).
  • Interactive console server.

Console data chunking breaks output

When long data is read by the editor to redirect, it is chunked to multiple parts. If the chunk is at the middle of a line, it will break the output.

Proposal:
If a not-ended line is read, cache it and it add it to the next read chunk's start.

Missing decorator lines from trace

When rendering trace decorator lines are not included.

We only include the lines from under if they are within the same expression, but as probably expected decorators do not have their own lines in bytecode either, instead they are bound the function or type definition's under them.

Propagate cancellation should include traceback

When using FutureSyncWrapper.wait with propagate_cancellation = True the task is cancelled, but no traceback of the cancellation is included. This means we can not debug the cancelled task.

As solutions, if the task is successfully cancelled, its cancellation traceback should be included.
If cancellation is unsuccessful, a RuntimeWarning should be used as cause.
This would need us to go back to the even loop for one more ready cycle.
Other solutions: Destroy the task if cancellation fails.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.