Skip to content

Conversation

@Nathanjp91
Copy link
Contributor

Problem

We now have linting and typechecking on the darwin-py future code but no non-manual way to ensure this code is up to scratch before creating a PR

Solution

Add in a typechecking optional pre/post commit hook script
install via ./.hooks/typechecking_installer.sh -o/-p -o default for post-commit (non-blocking warning) vs -p pre-commit (strictly enforced),

Changelog

Optional developer installable git hooks

Returns
-------
None
JSONType
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This and the other file change are just two minor changes to test that it was grabbing the right files

@@ -0,0 +1,111 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#!/bin/bash
#!/bin/env bash

☝🏻 better x-plat support on different machines nowadays. More of a good practice thing than anything because who doesn't have bash?

# Make sure these tools are installed and available in your system's PATH before running the script.

# Define the hook script
HOOK_SCRIPT="#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
HOOK_SCRIPT="#!/bin/bash
HOOK_SCRIPT="#!/bin/env bash

Same again, sorry, but I put a suggestion in so that you can accept or reject it easily!

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also probably EOF this, but if it ain't broke.

echo -e '\nRunning Black'
echo ----------------------------------------
BLACK_FAILED=0
black --check \$FILES || BLACK_FAILED=1
Copy link
Contributor

Choose a reason for hiding this comment

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

These could each be like

BLACK_FAILED=`black --check \$FILES`

and so on, with the same function, but again, if it ain't broke.

# Check if any linter failed
echo Summary
echo ----------------------------------------
if [ \$BLACK_FAILED -eq 1 ]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider escaped quotes around comparison variables. Prevents them going wrong in certain scenarios. Again, it's a good practice > required.

echo "Unknown option: $key"
exit 1
;;
esac
Copy link
Contributor

Choose a reason for hiding this comment

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

NGL, that's pretty nice case statement

@owencjones owencjones merged commit 1dd0e50 into master Oct 24, 2023
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.

3 participants