Add a makefile for helping with style checking and reformatting #1665

Merged
palmtree5 merged 11 commits from V3/add_makefile into V3/develop 2018-05-23 02:44:12 +02:00
palmtree5 commented 2018-05-15 20:58:01 +02:00 (Migrated from github.com)
No description provided.
Twentysix26 (Migrated from github.com) reviewed 2018-05-15 20:58:01 +02:00
mikeshardmind commented 2018-05-22 17:19:40 +02:00 (Migrated from github.com)

I have no issues with providing a makefile and a make.bat, but in this implementation, we're duplicating args passed to black, and also hard coding paths to check, while also including files which aren't python files.

This could be changed so that the makefile (and a make.bat) both point to tox -e style (only runs the style check) and have tox run a python file in that section which runs black against just the python files which are tracked by git.

I have no issues with providing a makefile and a make.bat, but in this implementation, we're duplicating args passed to black, and also hard coding paths to check, while also including files which aren't python files. This could be changed so that the makefile (and a make.bat) both point to `tox -e style` (only runs the style check) and have tox run a python file in that section which runs black against just the python files which are tracked by git.
Tobotimus commented 2018-05-22 17:26:10 +02:00 (Migrated from github.com)

As for hard-coded paths, that can easily be fixed by substituting those paths with git ls-files "*.py". Also, no matter what is passed as arguments, black will ignore all files except for .py and .pyi files, so including other files isn't a problem.

tox -e style is significantly slower than directly calling black from the makefile. Moreover, there's really not much we can change about black's arguments to warrant such concern for duplicating them, and I certainly don't think this needs yet another script.

As for hard-coded paths, that can easily be fixed by substituting those paths with `git ls-files "*.py"`. Also, no matter what is passed as arguments, black will ignore all files except for `.py` and `.pyi` files, so including other files isn't a problem. `tox -e style` is significantly slower than directly calling black from the makefile. Moreover, there's really not much we can change about black's arguments to warrant such concern for duplicating them, and I certainly don't think this needs yet another script.
mikeshardmind commented 2018-05-22 17:32:38 +02:00 (Migrated from github.com)

Then at the very least, doesn't it make more sense to provide the style check as a single cross platform python script and have tox's style check call that?

I'm envisioning how easy it would be to forget that this is used in 3 distinct locations 3 months down the line when some file not currently included in hardcoded paths is used, or if arguments to black are changed for some reason.

Then at the very least, doesn't it make more sense to provide the style check as a single cross platform python script and have tox's style check call that? I'm envisioning how easy it would be to forget that this is used in 3 distinct locations 3 months down the line when some file not currently included in hardcoded paths is used, or if arguments to black are changed for some reason.
tekulvw commented 2018-05-22 17:40:17 +02:00 (Migrated from github.com)

I really don't think it's that big of a deal. If we forget to add something down the line then Travis will tell us. However I really don't envision a scenario where we get swamped by new python files that magically appear outside the redbot and tests folders.

Simple is good, as-is this is simple and clear what it does. I don't think we need to over engineer this.

I really don't think it's that big of a deal. If we forget to add something down the line then Travis will tell us. However I really don't envision a scenario where we get swamped by new python files that magically appear outside the redbot and tests folders. Simple is good, as-is this is simple and clear what it does. I don't think we need to over engineer this.
Tobotimus commented 2018-05-22 17:40:27 +02:00 (Migrated from github.com)

[RE: mikeshardmind] Does it make more sense? I don't think so. I think it makes more sense to invoke command line applications from a Makefile or batch script than a python script.

As for what you're envisioning, I can't say I share the same view. This minuscule amount of information is duplicated across 2 files, not 3, and they're both makefiles, so it's intuitive to know that modifying one means modifying the other. I've already addressed the hardcoded paths in my previous comment.

[RE: mikeshardmind] Does it make more sense? I don't think so. I think it makes more sense to invoke command line applications from a Makefile or batch script than a python script. As for what you're envisioning, I can't say I share the same view. This minuscule amount of information is duplicated across 2 files, not 3, and they're both makefiles, so it's intuitive to know that modifying one means modifying the other. I've already addressed the hardcoded paths in my previous comment.
mikeshardmind commented 2018-05-22 17:43:37 +02:00 (Migrated from github.com)

The 3rd being tox.ini right now.

I also don't think programatically detecting which python files belong to the repository is over-engineering it. I think it's an easy way to avoid future mistakes.

The 3rd being tox.ini right now. I also don't think programatically detecting which python files belong to the repository is over-engineering it. I think it's an easy way to avoid future mistakes.
Tobotimus commented 2018-05-22 17:47:25 +02:00 (Migrated from github.com)

Avoiding the duplication in tox.ini is trivial, we can just call make from tox.

Avoiding the duplication in tox.ini is trivial, we can just call make from tox.
mikeshardmind commented 2018-05-22 18:04:18 +02:00 (Migrated from github.com)

Okay, so if calling make from tox, then it's a makefile and make.bat, which at least are clearly connected.

However, I still strongly disagree with @tekulvw on

I really don't think it's that big of a deal. If we forget to add something down the line then Travis will tell us. However I really don't envision a scenario where we get swamped by new pythpn files that magically appear outside the redbot and tests folders.

Simple is good, as-is this is simple and clear what it does. I don't think we need to over engineer this.

reformat:
	black -l 99 `git ls-files '*.py'`
stylecheck:
	black --check -l 99 `git ls-files '*.py'`

is no less clear as what is going on, remains simple, and does not run the risk of missing a tracked file.

Okay, so if calling make from tox, then it's a makefile and make.bat, which at least are clearly connected. However, I still strongly disagree with @tekulvw on > I really don't think it's that big of a deal. If we forget to add something down the line then Travis will tell us. However I really don't envision a scenario where we get swamped by new pythpn files that magically appear outside the redbot and tests folders. > > Simple is good, as-is this is simple and clear what it does. I don't think we need to over engineer this. ``` reformat: black -l 99 `git ls-files '*.py'` stylecheck: black --check -l 99 `git ls-files '*.py'` ``` is no less clear as what is going on, remains simple, and does not run the risk of missing a tracked file.
tekulvw (Migrated from github.com) approved these changes 2018-05-23 02:40:01 +02:00
Sign in to join this conversation.
No labels
Automated PR
Blocked
Blocked By: Damage Control
Blocked By: Dependency
Blocked By: Other PR
Breaking Change
Category: CI
Category: Cogs - Admin
Category: Cogs - Alias
Category: Cogs - Audio
Category: Cogs - Bank
Category: Cogs - Cleanup
Category: Cogs - CustomCommands
Category: Cogs - Dev
Category: Cogs - Downloader
Category: Cogs - Economy
Category: Cogs - Filter
Category: Cogs - General
Category: Cogs - Image
Category: Cogs - Mod
Category: Cogs - Modlog
Category: Cogs - Mutes
Category: Cogs - Permissions
Category: Cogs - Reports
Category: Cogs - Streams
Category: Cogs - Trivia
Category: Cogs - Trivia - Lists
Category: Cogs - Warnings
Category: Core - API - App Commands Package
Category: Core - API - Audio
Category: Core - API - Bank
Category: Core - API - Commands Package
Category: Core - API - Config
Category: Core - API - Other
Category: Core - API - Utils Package
Category: Core - Bot Class
Category: Core - Bot Commands
Category: Core - Command-line Interfaces
Category: Core - Downloader
Category: Core - Help
Category: Core - i18n
Category: Core - Modlog
Category: Core - Other Internals
Category: Core - RPC/ZMQ
Category: Docker
Category: Docs - Changelogs
Category: Docs - For Developers
Category: Docs - Install Guides
Category: Docs - Other
Category: Docs - User Guides
Category: Meta
Category: RPC/ZMQ methods
Category: Vendored Packages
Changelog Entry: Added
Changelog Entry: Pending
Changelog Entry: Skipped
Closed: Duplicate
Closed: External
Closed: Invalid
Closed: User Error
Closed: Won't Fix
Complex Issue
Docs-only
Feature Branch
Good First Issue
Help Wanted
High Priority
Needs Backport To stable-docs
No Activity
No Repro
QA: Bypassed
QA: Changes Requested
QA: Passed
Release Blocker
Status: Accepted
Status: Frozen
Status: In Progress
Status: Needs Discussion
Status: Needs Info
Status: Needs Triage
Status: PRs Welcome
Type: Bug
Type: Dependency Update
Type: Deprecation
Type: Enhancement
Type: Feature
Type: Informational
Type: Merge
Type: Optimisation
Type: Question
Type: Removal
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Mrcoolgamer11/Red-DiscordBot!1665
No description provided.