profile
viewpoint
If you are wondering where the data of this site comes from, please visit https://api.github.com/users/asottile/events. GitMemory does not store any data, but only uses NGINX to cache data for a period of time. The idea behind GitMemory is simply to give users a better reading experience.
Anthony Sottile asottile @pre-commit @pytest-dev @tox-dev

asottile/all-repos 272

Clone all your repositories and apply sweeping changes.

asottile/blacken-docs 260

Run `black` on python code blocks in documentation files

asottile/add-trailing-comma 189

A tool (and pre-commit hook) to automatically add trailing commas to calls and literals.

asottile/babi 152

a text editor

asottile/dead 128

dead simple python dead code detection

asottile/astpretty 116

Pretty print the output of python stdlib `ast.parse`.

asottile/dockerfile 54

Parse a dockerfile into a high-level representation using the official go parser

asottile/covdefaults 28

A coverage plugin to provide sensible default settings

asottile/azure-pipeline-templates 26

templates for azure pipelines

asottile/cfgv 25

Validate configuration and produce human readable error messages

GollumEvent

issue commentcontainers/podman

Broken update to 3.3.1 on Ubuntu 20.04

this is not working for me -- I am installing podman-rootless and seeing this error still:

$ podman run --rm -ti ubuntu:focal echo hi
WARN[0000] Error validating CNI config file /home/asottile/.config/cni/net.d/87-podman.conflist: [failed to find plugin "bridge" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "portmap" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "firewall" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "tuning" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin]] 
WARN[0002] Error validating CNI config file /home/asottile/.config/cni/net.d/87-podman.conflist: [failed to find plugin "bridge" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "portmap" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "firewall" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin] failed to find plugin "tuning" in path [/usr/libexec/cni /usr/lib/cni /usr/local/lib/cni /opt/cni/bin]] 
hi
zgoda

comment created time in 3 hours

GollumEvent

Pull request review commentpre-commit/pre-commit

Add warning for regular expression with [\/] (#2043)

 def check(self, dct: Dict[str, Any]) -> None:             )  +class OptionalSensibleSlashesAtHook(cfgv.OptionalNoDefault):+    def check(self, dct: Dict[str, Any]) -> None:+        super().check(dct)++        if r'[\/]' in dct.get(self.key, ''):+            logger.warning(+                f'Pre-commit normalizes the slashes in {self.key!r} field in '

pre-commit is not capitalized

radek-sprta

comment created time in 5 hours

Pull request review commentpre-commit/pre-commit

Add warning for regular expression with [\/] (#2043)

 def check(self, dct: Dict[str, Any]) -> None:             )  +class OptionalSensibleSlashesAtHook(cfgv.OptionalNoDefault):+    def check(self, dct: Dict[str, Any]) -> None:+        super().check(dct)++        if r'[\/]' in dct.get(self.key, ''):+            logger.warning(+                f'Pre-commit normalizes the slashes in {self.key!r} field in '+                f"hook {dct.get('id')!r} to forward slashes, so you can use "+                f'/ instead of [\\/]',+            )

I would just add these to the existing SensibleRegex checks

also this should check for both r'[\/]' and r'[/\]' since those are both valid spellings of "either slash"

radek-sprta

comment created time in 5 hours

Pull request review commentpre-commit/pre-commit

Add warning for regular expression with [\/] (#2043)

 def check(self, dct: Dict[str, Any]) -> None:             )  +class OptionalSensibleSlashesAtHook(cfgv.OptionalNoDefault):+    def check(self, dct: Dict[str, Any]) -> None:+        super().check(dct)++        if r'[\/]' in dct.get(self.key, ''):+            logger.warning(+                f'Pre-commit normalizes the slashes in {self.key!r} field in '+                f"hook {dct.get('id')!r} to forward slashes, so you can use "+                f'/ instead of [\\/]',+            )+++class OptionalSensibleSlashesAtTop(cfgv.OptionalNoDefault):+    def check(self, dct: Dict[str, Any]) -> None:+        super().check(dct)++        if r'[\/]' in dct.get(self.key, ''):+            logger.warning(+                f'Pre-commit normalizes the slashes in the top-level '+                f'{self.key!r} field to forward slashes, so you can use / '+                f'instead of [\\/]',

you can use fr'...' for a raw f-string by the way

radek-sprta

comment created time in 5 hours

PullRequestReviewEvent
PullRequestReviewEvent

push eventpre-commit/identify

Anthony Sottile

commit sha 8f349b59f356ece95d4defddb07a941187ea3f35

v2.2.15

view details

push time in 5 hours

created tagpre-commit/identify

tagv2.2.15

File identification library for Python

created time in 5 hours

push eventpre-commit/identify

Joshua Sleeper

commit sha 9c1b56622e84fa5c9875d6e84427a43be95df18d

add hcl extension support

view details

Anthony Sottile

commit sha a8c362da819d309687e3a09d7797eca4cc988cb7

Merge pull request #232 from joshsleeper/patch-1 add hcl extension support

view details

push time in 5 hours

PR merged pre-commit/identify

add hcl extension support

changes

  • add hcl extension support
  • alphabetize EXTENSIONS keys
    • they were mostly there already, but a few weren't quite right
+1 -0

2 comments

1 changed file

joshsleeper

pr closed time in 5 hours

pull request commentpre-commit/identify

add hcl extension support

one thought is to whether the existing terraform extensions should also set hcl -- but that can always be a followup

joshsleeper

comment created time in 5 hours

push eventjoshsleeper/identify

Joshua Sleeper

commit sha 9c1b56622e84fa5c9875d6e84427a43be95df18d

add hcl extension support

view details

push time in 5 hours

pull request commentpre-commit/identify

feat(hcl): add hcl extension support

yeah some of the extensions in EXTENSIONS are intentionally not alphabetized so they can be grouped near their relevant things (for example the nim sources are near each other and csproj was next to csharp)

joshsleeper

comment created time in 5 hours

issue commentpre-commit-ci/runner-image

R improvements

  • Although I suggested to --without-recommended-packages, I think we should not do that because some recommended packages are hard to build from source (when initializing the environment) and have system dependencies, and it won't add much to the size of the image to include it.

If there's specific ones to add that seems fine, building all of them doesn't seem productive though (for instance I don't think a linter will need generalized fortran extensions, hopefully).

  • I am still wondering if we can make the global renv cache work under /opt/R. Unit tests should cover this, so I might submit a PR.

The only persistent state which is kept between runs is inside the environment directory. Additionally runs are run as an unprivileged user which does not have write permission to the /opt directories (again, intentionally). As such, I don't think that enabling /opt/R as a cache helps or is possible.

  • After 120s, it seems like the installation of the environment is timed out. While this seems to make sense for most repos that host only one hook, mine hosts a lot of hooks and hence installation takes a bit longer (but is cached thanks to your work). There are two major R repos from which to get packages, and both only support binaries for either Linux or Windows/macOS. I assume most users will not use Linux, so I prefer to have binary R package install for them locally, which means Linux package installs will be from source. Hence, I propose to increase the timeout limit. Not sure what's needed here for my hooks, should we try to double it? The reason I managed to complete a run was because I temporarily switched to binaries for Linux.

I don't really want to bump this up, it's already quite long and any increase here significantly increases my risk from a cost and abuse perspective.

  • I anticipate some problems with missing system dependencies as some hooks have additional_dependencies:. In particular, my {roxygen2} hook requires the user to specify all runtime dependencies of his package as additional_dependencies: because {roxygen2} requires them (to generate the docs). There are tools in R to install these system dependencies, but they rely on apt and hence don't put the installed packages into /opt/R. We can also postpone this for now I think.

yeahhhh that's not really going to work so well. those'll probably just be unsupported (?). It seems a little bit weird to build docs as part of pre-commit -- I'd usually leave that to a testing phase

lorenzwalthert

comment created time in 5 hours

push eventasottile/ancient-pythons

int3l

commit sha 72a4df99e4a2e6dc4d3cc7e69b37efc109e13f51

Add int multiplication overflow check

view details

Anthony Sottile

commit sha 5a19c0143ed5a9c423c969f653e5f8fc78886f9f

Merge pull request #3 from int3l/master Add the integer multiplication overflow check again & fix make's std output

view details

push time in 5 hours

push eventint3l/ancient-pythons

int3l

commit sha 72a4df99e4a2e6dc4d3cc7e69b37efc109e13f51

Add int multiplication overflow check

view details

push time in 5 hours

issue commentPyCQA/flake8

Spurious warning from internal plugin

you're looking for mccabe's issue tracker -- as noted in the issue template, flake8 does not implement any plugins of it sown

kmurphy4

comment created time in 6 hours

issue closedPyCQA/flake8

Spurious warning from internal plugin

Please describe how you installed Flake8

$ python3.6 -m venv /tmp/venv
$ source /tmp/venv/bin/activate
$ pip install flake8==3.9.2

Please provide the exact, unmodified output of flake8 --bug-report

<details> <summary>

$ flake8 --bug-report

</summary>

{
  "dependencies": [],
  "platform": {
    "python_implementation": "CPython",
    "python_version": "3.6.9",
    "system": "Linux"
  },
  "plugins": [
    {
      "is_local": false,
      "plugin": "example",
      "version": "0.1.0"
    },
    {
      "is_local": false,
      "plugin": "mccabe",
      "version": "0.6.1"
    },
    {
      "is_local": false,
      "plugin": "pycodestyle",
      "version": "2.7.0"
    },
    {
      "is_local": false,
      "plugin": "pyflakes",
      "version": "2.3.1"
    }
  ],
  "version": "3.9.2"
}

</details>

Please describe the problem or feature

I'm trying to create a custom plugin for flake8. This is working great overall, but I'm encountering one small logging bug. Every time I run flake8 after installing my plugin, I get this warning (from the internal mccabe plugin).

option --max-complexity: please update from optparse string `type=` to argparse callable `type=` -- this will be an error in the future

If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.

Here's a minimal reproduction:

# setup.py
import setuptools
setuptools.setup()
# setup.cfg
[metadata]
name = example
version = 0.1.0

[options]
py_modules = example
install_requires =
  flake8

[options.entry_points]
flake8.extension =
  EXE101 = example:ExamplePlugin
# example.py
import logging


# Set up a basic logger to write to stderr
logger = logging.getLogger()
handler = logging.StreamHandler()
logger.addHandler(handler)

# Log everything for WARNING + above
logger.setLevel(logging.WARNING)


class ExamplePlugin:
    name = "example"
    version = "0.1.0"

    def __init__(self, tree):
        pass

    def run(self):
        yield from []  # empty yield needs a `yield` keyword :)

(installed via $ pip install -e .)

Setting a breakpoint here and typing up a couple times reveals that this is in fact being triggered by the mccabe checker:

> /tmp/venv/lib/python3.6/site-packages/flake8/plugins/manager.py(402)generated_function()
-> return method(optmanager, *args, **kwargs)
(Pdb) ll
399  	        def generated_function(plugin):  # noqa: D105
400  	            method = getattr(plugin, method_name, None)
401  	            if method is not None and callable(method):
402  ->	                return method(optmanager, *args, **kwargs)
(Pdb) p plugin
Plugin(name="C90", entry_point="mccabe:McCabeChecker")

I can work around this warning for now by explicitly setting the logging configuration for that module, e.g.,

logging.getLogger("flake8.options.manager").setLevel(logging.ERROR)

but that feels brittle and unreliable (plus it might suppress some warnings I do want to see).

Let me know if there's any more details I can provide!

closed time in 6 hours

kmurphy4

Pull request review commentasottile/blacken-docs

Format invisible doctest code blocks

     rf'(?P<before>'     rf'^(?P<indent> *)\.\. ('     rf'jupyter-execute::|'+    rf'invisible-code-block::?|'

this would handle all code blocks which isn't correct -- it needs to specifically be python code blocks

Zac-HD

comment created time in 6 hours

PullRequestReviewEvent

pull request commentasottile/ancient-pythons

Add the integer multiplication overflow check again & fix make's std output

I think check=True is actually the easiest patch

int3l

comment created time in a day

pull request commentasottile/ancient-pythons

Add the integer multiplication overflow check again & fix make's std output

BTW😂:

image

I am amazed that works! wow!

int3l

comment created time in a day

PullRequestReviewEvent

Pull request review commentasottile/ancient-pythons

Add the integer multiplication overflow check again & fix make's std output

 def output_on_failure(cmd, cwd):     print(f'$ cd {cwd} && {cmd}')     ret = subprocess.run(-        cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd,+        cmd,+        cwd=cwd,+        stdout=subprocess.PIPE,+        stderr=subprocess.STDOUT,+        universal_newlines=True,

universal_newlines has the same problem as .decode() or encoding=... or text=True in that it hides the actual error on a decoding issue

int3l

comment created time in a day

Pull request review commentasottile/ancient-pythons

Add the integer multiplication overflow check again & fix make's std output

 def output_on_failure(cmd, cwd):     )     if ret.returncode:         raise AssertionError('Command {!r} returned {}!\nOutput:\n{}'.format(-            cmd, ret.returncode, ret.stdout,+            cmd, ret.returncode, ret.stdout.decode(),

skipping the decode here was ~partially intentional (non-UTF-8 code would crash while producing an error message instead of showing the error message)

int3l

comment created time in a day

PullRequestReviewEvent

push eventanthonywritescode/explains

int3l

commit sha 069d83f3450e6eeb93283e409ec02b121c0f3616

Add code examples for episode 335 & 336

view details

Anthony Sottile

commit sha d3c6ab741772e46764ff637f3f9d2ab9a9683488

Merge pull request #209 from int3l/master Code examples for episode 335 & 336

view details

push time in a day