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

Issue with pre-commit or mypy #21

Closed
NoraLoose opened this issue Feb 10, 2021 · 6 comments
Closed

Issue with pre-commit or mypy #21

NoraLoose opened this issue Feb 10, 2021 · 6 comments

Comments

@NoraLoose
Copy link
Member

I am ready to submit a pull request, but I am having issues with pre-commit, specifically mypy.

(gcm-filters-env) noraloose:~/gcm-filters> pre-commit run --all-files

[WARNING] The 'rev' field of repo 'https://github.com/psf/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.
Trim Trailing Whitespace.................................................Passed
Check python ast.........................................................Passed
Debug Statements (Python)................................................Passed
Fix End of Files.........................................................Passed
Check docstring is first.................................................Passed
Check for added large files..............................................Passed
Fix requirements.txt.....................................................Passed
File Contents Sorter.....................................................Passed
flake8...................................................................Passed
isort....................................................................Passed
seed isort known_third_party.............................................Passed
black....................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 2

gcm_filters/filter.py:55: error: syntax error in type comment
gcm_filters/filter.py:57: error: syntax error in type comment
Found 2 errors in 1 file (checked 8 source files)

This points me to 2 lines in filter.py, even though I did not touch that file.

class FilterSpec(NamedTuple):
n_lap_steps: int
s_l: Iterable[float]
n_bih_steps: int
s_b: Iterable[complex]

I continued and ignored the filter.py file, since I only want to commit changes in kernel.py:

git add gcm_filters/kernels.py
git commit -m "move computation of wet_fac to post_init"

[WARNING] The 'rev' field of repo 'https://github.com/psf/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.
Trim Trailing Whitespace.................................................Passed
Check python ast.........................................................Passed
Debug Statements (Python)................................................Passed
Fix End of Files.........................................................Passed
Check docstring is first.................................................Passed
Check for added large files..............................................Passed
Fix requirements.txt.................................(no files to check)Skipped
File Contents Sorter.................................(no files to check)Skipped
flake8...................................................................Passed
isort....................................................................Passed
seed isort known_third_party.............................................Passed
black....................................................................Passed
mypy.....................................................................Failed
- hook id: mypy
- exit code: 2

gcm_filters/kernels.py:16: error: syntax error in type comment
Found 1 error in 1 file (checked 1 source file)

Again, the error points me to lines that I haven't touched:

# not married to the term "Cartesian"
GridType = enum.Enum("GridType", ["CARTESIAN", "CARTESIAN_WITH_LAND"])
ALL_KERNELS = {} # type: Dict[GridType, Any]

All my changes to be commited are further down in that file, in CartesianLaplacianWithLandMask(BaseLaplacian).

Any ideas how to fix these issues?

@rabernat
Copy link
Contributor

Thanks @NoraLoose for getting started on this!

Any ideas how to fix these issues?

I don't want to get stuck on this, so please just disable the mypy check for now by commenting out these lines

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.770
hooks:
- id: mypy
exclude: docs/source/conf.py
args: [--ignore-missing-imports]

@jbusecke - just like in #20, pre-commit is complaining about errors in a file that the user has not touched. I don't understand how this can be possible. We need to figure this out or else just disable pre-commit, as it is making it harder for others to contribute (rather than easier, which was the intent).

@NoraLoose
Copy link
Member Author

Thanks @rabernat for the quick response! I followed your recommendation, and disabled the mypy check.

@NoraLoose
Copy link
Member Author

Since we are at it, I encountered a different issue with pre-commit on casper:

pre-commit run --all-files

[WARNING] The 'rev' field of repo 'https://github.com/psf/black' appears to be a mutable reference (moving tag / branch).  Mutable references are never updated after first install and are not supported.  See https://pre-commit.com/#using-the-latest-version-for-a-repository for more details.
[INFO] Initializing environment for https://gitlab.com/pycqa/flake8.
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/git', 'fetch', 'origin', '--tags')
return code: 128
expected return code: 0
stdout: (none)
stderr:
    error: RPC failed; result=22, HTTP code = 422
    fatal: The remote end hung up unexpectedly
    
Check the log at /glade/u/home/noraloose/.cache/pre-commit/pre-commit.log

I checked the log file, but I'm still not sure what the issue is. I moved to my local machine and then pre-commit worked (except for the issues above).

@rabernat
Copy link
Contributor

hmmm 🧐 ... This latter issue might be a network problem. Does the casper node where you are running have access to the internet? Pre-commit needs to access the internet to install itself the first time it is run.

You could try doing all your git commits and pre-commit from a head node to work around this problem.

@jbusecke
Copy link
Collaborator

Yeah this is not great. Let me disable mypy for now, I do not view it as essential and useful as e.g. black (which causes less issues in my experience). Does that sound good?

@rabernat
Copy link
Contributor

It is commented out already in #22. Let's not do anything right now that would lead to a merge conflict.

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

3 participants