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

No sorting for methods, properties etc. #101

Closed
slafs opened this issue Aug 23, 2023 · 3 comments
Closed

No sorting for methods, properties etc. #101

slafs opened this issue Aug 23, 2023 · 3 comments

Comments

@slafs
Copy link

slafs commented Aug 23, 2023

When having a file like this:

class Foo:
    # simple methods
    def foo2(self):
        return self.foo1()

    def foo1(self):
        return 1

    # property
    def foo_prop2(self):
        return self.foo_prop1

    @property
    def foo_prop1(self):
        return 2

    # classmethod
    def foo_classmethod2(self):
        return self.foo_classmethod1()

    @classmethod
    def foo_classmethod1(cls):
        return 3

    # staticmethod
    def foo_static2(self):
        return self.foo_static1()

    @staticmethod
    def foo_static1():
        return 4

and running ssort --diff on it,

ssort doesn't modify the file at all (1 file was left unchanged).

I'd expect that all members of Foo class with suffix 1 to be sorted in the way they appear before the respective ones with suffix 2.

Am I missing something? I thought ssort was handling such cases 🤔.

@bwhmather
Copy link
Owner

Sorry for slow response. ssort used to try to sort class methods and attributes topologically, but we found that this conflicted with automatic grouping based on type (attributes, constructors, special attributes, regular methods, etc) and so we stopped doing it.

At the file level, there aren't the same natural groups (except for maybe imports and if __name__ == "__main__":) and things tend to end up as graphs rather than a bag of methods that manipulate the same state.

@bwhmather
Copy link
Owner

(related discussion here: #11)

@bwhmather
Copy link
Owner

Closing as duplicate of #11

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

No branches or pull requests

2 participants