Readit News logoReadit News
Jackevansevo commented on Pytest for Neovim   github.com/richardhapb/py... · Posted by u/richardhapb
ryan-duve · 5 months ago
Could you share an example of a workflow using the built in feature to run tests in Vim?
Jackevansevo · 5 months ago
Sure, here's a recorded example: https://www.youtube.com/watch?v=TUeousvp4PQ
Jackevansevo commented on Pytest for Neovim   github.com/richardhapb/py... · Posted by u/richardhapb
richardhapb · 5 months ago
Interesting approach! Can you share more about this?
Jackevansevo · 5 months ago
Rather than write something up or linking to a bunch of articles I recorded a quick screen capture: https://www.youtube.com/watch?v=TUeousvp4PQ
Jackevansevo commented on Pytest for Neovim   github.com/richardhapb/py... · Posted by u/richardhapb
Jackevansevo · 5 months ago
For the longest time I've been using vims built-in `compiler` feature with tartansandal/vim-compiler-pytest combined tpope/vim-dispatch
Jackevansevo commented on GitHub cuts AI deals with Google, Anthropic   bloomberg.com/news/articl... · Posted by u/jbredeche
AIorNot · 10 months ago
Reviewing these conversations is like listening to horse and buggy manufacturers pooh-poohing automobiles:

1. they will scare the horses. a good team of horses is no match for funky 'automobile'

2. how will they be able to deal with our muddy, messy roads

3. their engines are unreliable and prone to breaking down stranding you in the middle and having to do it yourself..

4. their drivers cant handle the speed, too many miles driven means unsafe driving.. we should stick to horses they are manageable.

Meanwhile I'm watching a community of mostly young people building and using tools like copilot, cursor, replit, jacob etc and wiring up LLMs into increasingly more complex workflows.

this is snapshot of the current state, not a reflection of the future- Give it 10 years

Jackevansevo · 10 months ago
> Meanwhile I'm watching a community of mostly young people building and using tools like copilot, cursor, replit, jacob etc and wiring up LLMs into increasingly more complex workflows.

And yet, I don't see much evidence that software quality is improving, if anything it seems in rapid decline.

Jackevansevo commented on Refactoring Python with Tree-sitter and Jedi   jackevans.bearblog.dev/re... · Posted by u/todsacerdoti
seanhunter · a year ago
Tree-sitter is really powerful, but it's worth people learning a few methods they prefer to use because there are going to be situations where one method works better than another. Things I have found useful in the past include

- perl -pi -e 's/foo/bar/g' files

"-pi" means "in place edit" so it will change the files in place. If you have a purely mechanical change like he's doing here it's a very reasonable choice. If you're not as much of a cowboy as I am, you can specify a suffix and it will back the files up, so something like

perl -p -i.bak -e 's/db/database/g'

py

For example then all your original '.py' files will be copied to '.py.bak' and the new renamed versions will be '.py'

For vim users (I know emacs has the same thing but I don't remember the exact invocation because it has been >20years since I used emacs as my main editor) it's worth knowing the "global" command. So you can execute a particular command only on lines that match some regex. So say you want to delete all the lines which mention cheese

:%g/cheese/d

Say you want to replace "db" with "database" but only on lines which start with "def"

:%g/^def/s/db/database/

OK cool. Now if you go 'vim *py' you can do ":argdo g/^def/s/db/database/ | update" and it will perform that global command across all the files in the arg list and save the ones which have changed.

Jackevansevo · a year ago
Author here: I'm super familiar with this kind of find and replace syntax inside vim or with sed. Usually it works great!

But in this specific situation it was tricky to handle situations with things spanning over multiple lines + preventing accidental renames.

Jackevansevo commented on Refactoring Python with Tree-sitter and Jedi   jackevans.bearblog.dev/re... · Posted by u/todsacerdoti
alexpovel · a year ago
These sorts of cases are why I wrote srgn [0]. It's based on tree-sitter too. Calling it as

     cat file.py | srgn --py def --py identifiers 'database' 'db'
will replace all mentions of `database` inside identifiers inside (only!) function definitions (`def`) with `db`.

An input like

    import database
    import pytest


    @pytest.fixture()
    def test_a(database):
        return database


    def test_b(database):
        return database


    database = "database"


    class database:
        pass

is turned into

    import database
    import pytest


    @pytest.fixture()
    def test_a(db):
        return db


    def test_b(db):
        return db


    database = "database"


    class database:
        pass

which seems roughly like what the author is after. Mentions of "database" outside function definitions are not modified. That sort of logic I always found hard to replicate in basic GNU-like tools. If run without stdin, the above command runs recursively, in-place (careful with that one!).

Note: I just wrote this, and version 0.13.2 is required for the above to work.

[0]: https://github.com/alexpovel/srgn

Jackevansevo · a year ago
This is super cool! I wish I'd known about this.
Jackevansevo commented on Refactoring Python with Tree-sitter and Jedi   jackevans.bearblog.dev/re... · Posted by u/todsacerdoti
nfrankel · a year ago
I wonder if the author has ever heard something called an IDE?
Jackevansevo · a year ago
Author here, I'm not aware of any IDE that can do this specific refactor
Jackevansevo commented on MiniJinja: Learnings from Building a Template Engine in Rust   lucumr.pocoo.org/2024/8/2... · Posted by u/todsacerdoti
Jackevansevo · a year ago
To add some balance to everyone slating Jinja in the comments, I've personally found it great to use.

Sure you CAN write unmaintainable business logic spaghetti in your templates, doesn't mean you SHOULD (Most criticism appears to come from this angle).

Jackevansevo commented on Mozilla roll out first AI features in Firefox Nightly   blog.mozilla.org/en/produ... · Posted by u/sharpshadow
Jackevansevo · a year ago
Mozilla forever determined to do anything but actually improve their core product.

I know it's opt-in, but nobody is going to switch to a browser because they ship this kinda stuff.

Jackevansevo commented on Oh My Zsh   ohmyz.sh/... · Posted by u/praash
Jackevansevo · 2 years ago
The defaults it ships out of the box makes the shell actually usable. Unsure I could ever go back to a regular bash/zsh prompt.

A lot of people will tell you this is slow and you've got to use X,Y,Z instead. If you're new, I'd strongly recommend just sticking with this, it's much easier to configure.

u/Jackevansevo

KarmaCake day264January 11, 2017View Original