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

basedpyright: init at 1.12.3 #308503

Merged
merged 1 commit into from
May 24, 2024
Merged

basedpyright: init at 1.12.3 #308503

merged 1 commit into from
May 24, 2024

Conversation

kiike
Copy link
Member

@kiike kiike commented May 2, 2024

Description of changes

This PR introduces a package for basedpyright, a fork of Microsoft's pyright that introduces some changes such as introduction of some improved unreachable code heuristics, banning of types, and adding features that would be only available with Pylance.

Closes #306129

Things done

Since this packages a fork, I used the existing pyright package.nix by @kalekseev (thanks!) and changed the variables accordingly. I changed the executable paths so hopefully both pyright and basedpyright can coexist side-by-side.

I checked the functionality of the binaries using the helix editor. Instructions for testing this kind of setup will be in a comment below.

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@kiike
Copy link
Member Author

kiike commented May 2, 2024

To test:

  1. I have started a nix-shell with nix shell .#basedpyright
  2. included the basedpyright helix config in my home-manager config:
programs.helix.languages."language-server" = {
  basedpyright = {
    command = "basedpyright-langserver";
    args = [ "--stdio" ];
    config = { };
    };
};
  1. Included the config in a Python project:
cat .helix/languages.toml
[[language]]
name = "python"
language-servers = ["basedpyright"]
  1. Tested whether the configuration is fine:
hx --health python
Configured language servers:
  ✓ basedpyright-langserver: /nix/store/zrlvsrsflb7d8yxww42fgs4g12vcr47n-basedpyright-1.11.0/bin/basedpyright-langserver
Configured debug adapter: python3
Binary for debug adapter: /nix/store/3v2ch16fkl50i85n05h5ckss8pxx6836-python3-3.11.8/bin/python3
Configured formatter: None
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓

image

@getchoo
Copy link
Member

getchoo commented May 3, 2024

Result of nixpkgs-review pr 308503 run on aarch64-linux 1

1 package built:
  • basedpyright

@kiike kiike requested a review from kalekseev May 9, 2024 07:51
@kiike
Copy link
Member Author

kiike commented May 9, 2024

Hi @kalekseev! Seeing that you reviewed and developed the pyright package, would you like to review this?

UPDATE: I've updated the package:

 cat << EOF > test.py; basedpyright --version; basedpyright test.py
import sys

if sys.platform == "win32":
    a = "a" + 1
EOF
basedpyright 1.12.1
based on pyright 1.1.362
/home/kiike/projects/nixpkgs/test.py
  /home/kiike/projects/nixpkgs/test.py:4:5 - error: Type of "a" is unknown (reportUnknownVariableType)
  /home/kiike/projects/nixpkgs/test.py:4:9 - error: Operator "+" not supported for types "Literal['a']" and "Literal[1]" (reportOperatorIssue)
2 errors, 0 warnings, 0 notes

@kiike kiike changed the title basedpyright: init at 1.11.0 basedpyright: init at 1.12.1 May 9, 2024
@kiike kiike force-pushed the pkgs/basedpyright branch 3 times, most recently from f958d5d to 695099b Compare May 9, 2024 18:38
@kalekseev
Copy link
Contributor

Hi @kalekseev! Seeing that you reviewed and developed the pyright package, would you like to review this?

Looks good to me but I don't have rights to merge.

@pluiedev
Copy link
Contributor

Result of nixpkgs-review pr 308503 run on x86_64-linux 1

1 package built:
  • basedpyright

@kiike
Copy link
Member Author

kiike commented May 10, 2024

Thank you both for your approvals!

@kiike kiike changed the title basedpyright: init at 1.12.1 basedpyright: init at 1.12.2 May 15, 2024
@kiike
Copy link
Member Author

kiike commented May 15, 2024

Updated to latest version released today.

 nix shell .#basedpyright -L
[...]

 cat << EOF > test.py; basedpyright --version; basedpyright test.py
import sys

if sys.platform == "win32":
    a = "a" + 1
EOF
basedpyright 1.12.2
based on pyright 1.1.363
/home/kiike/projects/nixpkgs/test.py
  /home/kiike/projects/nixpkgs/test.py:4:5 - error: Type of "a" is unknown (reportUnknownVariableType)
  /home/kiike/projects/nixpkgs/test.py:4:9 - error: Operator "+" not supported for types "Literal['a']" and "Literal[1]" (reportOperatorIssue)
2 errors, 0 warnings, 0 notes

Copy link
Contributor

@pluiedev pluiedev left a comment

Choose a reason for hiding this comment

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

Works great!

@GaetanLepage
Copy link
Contributor

Result of nixpkgs-review pr 308503 run on aarch64-linux 1

1 package built:
  • basedpyright

@GaetanLepage
Copy link
Contributor

Result of nixpkgs-review pr 308503 run on aarch64-darwin 1

1 package built:
  • basedpyright

@GaetanLepage
Copy link
Contributor

Result of nixpkgs-review pr 308503 run on x86_64-linux 1

1 package built:
  • basedpyright

@GaetanLepage
Copy link
Contributor

Result of nixpkgs-review pr 308503 run on x86_64-darwin 1

1 package built:
  • basedpyright

@kiike
Copy link
Member Author

kiike commented May 23, 2024

Updated to 1.12.3 released yesterday:

Changelog:

update upstream pyright version to 1.1.364 by @DetachHead in DetachHead/basedpyright#375
fix Any being coloured as a variable instead of a type by @DetachHead in DetachHead/basedpyright#373
documentation enhancements
new URL: https://docs.basedpyright.com/
explain how to use the CLI & language server from pypi and make it clear that many of the IDE plugins require them to be installed by @DetachHead in DetachHead/basedpyright#366
Improve Neovim installation instructions by @baco in DetachHead/basedpyright#368

Full Changelog: DetachHead/basedpyright@v1.12.2...v1.12.3

Testing it in a shell with nix shell .#basedpyright -L.

Copy & paste command:

cat << EOF > test.py; basedpyright --version; basedpyright test.py
import sys

if sys.platform == "win32":
    a = "a" + 1
EOF

Output:

basedpyright 1.12.3
based on pyright 1.1.364
/home/kiike/projects/nixpkgs/test.py
  /home/kiike/projects/nixpkgs/test.py:4:5 - error: Type of "a" is unknown (reportUnknownVariableType)
  /home/kiike/projects/nixpkgs/test.py:4:9 - error: Operator "+" not supported for types "Literal['a']" and "Literal[1]" (reportOperatorIssue)
2 errors, 0 warnings, 0 notes

@kiike kiike requested a review from GaetanLepage May 23, 2024 10:36
@kiike kiike changed the title basedpyright: init at 1.12.2 basedpyright: init at 1.12.3 May 23, 2024
Copy link
Contributor

@GaetanLepage GaetanLepage left a comment

Choose a reason for hiding this comment

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

LGTM !

@GaetanLepage
Copy link
Contributor

GaetanLepage commented May 24, 2024

I would squash all the commits into one: basedpyright: init at 1.12.3.


dontNpmBuild = true;

passthru.updateScript = nix-update-script { };
Copy link
Member

Choose a reason for hiding this comment

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

Does this update script work properly?
The original pyright has its own script.

Copy link
Member Author

Choose a reason for hiding this comment

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

The original script didn't work for me. I tried nix-update-script and it worked.

@kiike
Copy link
Member Author

kiike commented May 24, 2024

I would squash all the commits into one: basedpyright: init at 1.12.3.

Done!

use nix-update

basedpyright: 1.11.0 -> 1.12.1

basedpyright: 1.12.2 -> 1.12.2

Diff:
DetachHead/basedpyright@v1.12.2...v1.12.2

Changelog:
https://github.com/detachhead/basedpyright/releases/tag/1.12.2

basedpyright: 1.12.2 -> 1.12.3

Changelog:
DetachHead/basedpyright@v1.12.2...v1.12.3
Copy link
Member

@natsukium natsukium left a comment

Choose a reason for hiding this comment

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

LGTM, thank you!

@natsukium natsukium merged commit e4df81c into NixOS:master May 24, 2024
23 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package request: python3packages.basedpyright
7 participants