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

Add configurable attributes order #10

Merged
merged 3 commits into from
Mar 15, 2020
Merged

Conversation

cepbuch
Copy link
Contributor

@cepbuch cepbuch commented Mar 14, 2020

closes #8

Added support of manually configurable attributes ordering such as:

[flake8]
class_attributes_order =
    field,
    meta_class,
    nested_class,
    magic_method,
    property_method,
    static_method,
    class_method,
    method,
    private_method

While trying to make it flexible (e.g. not to force users to set all the node types manually), I'm still not sure that my solution is permissible in terms of performance, but looks like it works fine and still no additional complexity was added to "default" and "strict" modes

Any improvement suggestions are accepted with pleasure

@cepbuch cepbuch force-pushed the master branch 2 times, most recently from c356d24 to 3079571 Compare March 14, 2020 23:24
Copy link
Contributor

@Melevir Melevir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a warning from comment above and some unit tests to prove, that new feature works fine and no old behavior is broken.

break

return node_type_weights
elif ClassAttributesOrderChecker.use_strict_mode:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we should fire a warning if both class_attributes_order and use_strict_mode are specified.

@Melevir
Copy link
Contributor

Melevir commented Mar 15, 2020

Thanks a lot for the pr! Please provide some additional work on comments above.

@cepbuch cepbuch requested a review from Melevir March 15, 2020 11:58
@cepbuch
Copy link
Contributor Author

cepbuch commented Mar 15, 2020

Fixed!

Also FYI: I had issues with running test locally (the problem is described in the link below). So I guess either attrs==19.1.0 version should be fixed in requirements.txt or pytest updated.

pytest-dev/pytest#3280 (comment)

@Melevir Melevir merged commit 83b3471 into best-doctor:master Mar 15, 2020
@Melevir
Copy link
Contributor

Melevir commented Mar 15, 2020

Thanks again!

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

Successfully merging this pull request may close these issues.

Make methods order configurable via setup.cfg
2 participants