Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code #92

Open
cgahr opened this issue May 1, 2023 · 0 comments
Open

Refactor code #92

cgahr opened this issue May 1, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@cgahr
Copy link
Collaborator

cgahr commented May 1, 2023

I'm currently going through the code to understand what's going on.

For reference, the current dependency graph in the project looks as follows (assume #84 gets merged; created using pydeps):
ssort_old

To be completely honest, I am very much confused by what does what. So I propose the following: refactor the code.

Step 1

As a first step, I'd like to remove ssort._utils and move its functions to different locations:
Right now there are the following functions defined in _utils.py:

cached_method
detect_encoding
detect_newline
escape_path
normalize_newline
single_dispatch
sort_key_from_iter

Each of these functions is only used in very few places:

cached_method:
    _statements.py
detect_encoding, detect_newline, normalize_newline:
    _main.py
    _ssort.py
escape_path:
    _main.py
single_dispatch:
    _ast.py
    _method_requirements.py
    _bindings.py
    _requirements.py
sort_key_from_iter:
    _graph.py

I propse to move these functions to the following files:

cached_method -> _statements.py
detect_encoding -> _files.py
detect_newline -> _files.py
escape_path -> _files.py
normalize_newline -> _files.py
single_dispatch -> _single_dispatch.py
sort_key_from_iter -> _graphs.py

The resulting graph looks as follows:
ssort

#91 implements these changes.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants