Skip to content

Conversation

@jakkdl
Copy link
Member

@jakkdl jakkdl commented Mar 10, 2023

Split out shed for more granular control of the underlying tools, also added auto-formatting for yaml&toml and other minor config changes.

Comment on lines -21 to +44
- hypothesis
- hypothesmith
- pytest
- flake8
- trio
- anyio
- anyio
- flake8
- hypothesis
- hypothesmith
- pytest
- trio
Copy link
Member Author

Choose a reason for hiding this comment

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

sorted

Comment on lines +56 to +57
- id: check-merge-conflict
- id: check-toml
Copy link
Member Author

Choose a reason for hiding this comment

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

sorted, and added these two

rev: 6.0.0
hooks:
- id: flake8
types_or: [python, pyi]
Copy link
Member Author

Choose a reason for hiding this comment

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

very important that this is types_or and not types, else it only checked stub files 😅

Comment on lines +74 to +87
- flake8-2020
- flake8-bugbear
- flake8-builtins
- flake8-comprehensions
- flake8-datetimez
- flake8-docstrings
- flake8-mutable
- flake8-noqa
- flake8-pie
- flake8-pyi
- flake8-pytest-style
- flake8-return
- flake8-simplify
- flake8-type-checking
Copy link
Member Author

@jakkdl jakkdl Mar 10, 2023

Choose a reason for hiding this comment

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

sorted, and remove some duplicates (!!)

Comment on lines +101 to +110
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
rev: 0.2.2
hooks:
- id: yamlfmt

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.7.0
hooks:
- id: pretty-format-toml
args: [--autofix]
Copy link
Member Author

Choose a reason for hiding this comment

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

added

@@ -1,13 +1,30 @@
[tool.pyright]
Copy link
Member Author

Choose a reason for hiding this comment

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

file sorted, and autoflake+isort added, pyright&codespell unchanged

Comment on lines +19 to +31
in_import: bool | None = None
with open(visitor_dir / "__init__.py") as f:
for line in f:
if m := re.match(r"from \. import (?P<module>\w*)", line):
if m := re.fullmatch(r"from \. import \(\n", line):
in_import = True
elif in_import and (m := re.fullmatch(r" *(?P<module>\w*),\n", line)):
visited_files.add(m.group("module"))
elif in_import and re.fullmatch(r"\)\n", line):
in_import = False

# check that parsing succeeded
assert in_import is False

Copy link
Member Author

Choose a reason for hiding this comment

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

required new logic with formatting change in the __init__.py

flake8_trio
*/site-packages/flake8_trio

[flake8]
Copy link
Member Author

Choose a reason for hiding this comment

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

moved so the coverage sections were next to eachother, and removed comment about Y021/Y048

@Zac-HD
Copy link
Member

Zac-HD commented Mar 12, 2023

What's the problem with just using shed? Probably obvious, but I really like having a single standard configuration across all my projects.

Could the issue be addressed by disabling shed for some test files and only using black there?

@jakkdl
Copy link
Member Author

jakkdl commented Mar 13, 2023

The current issue is very specifically that I want to disable autoflake removing pass for autofix_files. The particular checks I want to run for those files I don't fully know, and while just running Black would probably be fine, I would prefer to default to running everything on the semi-generated code to alert me of any possible weird stuff going on asap, so I can fix it or be aware of the limitation. I could maybe also/instead stop blanket disabling flake8 for eval_ & autofix_files.

But given how much I've fought with shed in the past with eval_files, and even occasionally with e.g. the imports in visitors/__init__.py, I personally prefer to have a bit more control than shed currently allows. (but definitely not as much as e.g. isort, that's just a crazy amount of config 😅) So yeah, that's why I've asked for any ways of making marginal changes to shed's behaviour.

It's also sometimes been frustrating to track down why a diff is generated, when shed modifies a file I either have to debug, or manually run the underlying tools, if/when I want to know what tool it is that generated the diff. Sometimes this is for requesting bugs/features in those tools/shed, or when I want to know whether to add # noqa, # isort: skip and/or fmt: off.

tl;dr, we could def go back to shed if you insist - but I do find it frustrating/limiting at times, aside from the current autoflake pass problem which prompted this.

Copy link
Member

@Zac-HD Zac-HD left a comment

Choose a reason for hiding this comment

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

Makes sense!

I'm always a bit 😥 when shed isn't the right choice, but in this case I agree it's better to use the underlying tools directly.

@Zac-HD Zac-HD merged commit 7c293f7 into python-trio:main Mar 13, 2023
@jakkdl jakkdl deleted the split_shed branch March 14, 2023 00:23
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.

2 participants