Skip to content

feat(onboarding): add poetry as an option to python install snippets#90365

Merged
shellmayr merged 12 commits intomasterfrom
shellmayr/feat/add-poetry-to-python-install-snippets
May 7, 2025
Merged

feat(onboarding): add poetry as an option to python install snippets#90365
shellmayr merged 12 commits intomasterfrom
shellmayr/feat/add-poetry-to-python-install-snippets

Conversation

@shellmayr
Copy link
Member

@shellmayr shellmayr commented Apr 25, 2025

  • Add poetry as an option in the python installation instructions along with pip and uv
  • Move adding of quotation marks into the central utility for consistency & use double quotation marks after alignment with Python SDK team
  • Add tests for the install instructions utility

Example:
Screenshot 2025-04-29 at 10 48 37

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Apr 25, 2025
@shellmayr shellmayr marked this pull request as ready for review April 28, 2025 08:41
@shellmayr shellmayr requested a review from a team as a code owner April 28, 2025 08:41
@shellmayr shellmayr requested review from a team and antonpirker and removed request for a team April 28, 2025 08:41
@codecov
Copy link

codecov bot commented Apr 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #90365      +/-   ##
==========================================
- Coverage   87.82%   83.15%   -4.67%     
==========================================
  Files       10267    10280      +13     
  Lines      579568   579158     -410     
  Branches    22622    22648      +26     
==========================================
- Hits       508984   481599   -27385     
- Misses      70150    97121   +26971     
- Partials      434      438       +4     

@priscilawebdev
Copy link
Member

we probably want to remove the quotes here too:

configurations: getPythonInstallConfig({packageName: "'sentry-sdk[falcon]'"}),

minimumVersion,
}),
},
{
Copy link
Member

Choose a reason for hiding this comment

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

since all of the 3x packages are being used here. what about just return

return {
    uv: `uv add ${upgradeFlag}${versionedPackage}`,
    pip: `pip install ${upgradeFlag}${versionedPackage}`,
    poetry: `poetry add ${versionedPackage}`,
  }

in the getPythonInstallSnippet? this way we don't need to call the function 3x times but only 1x and we can do pythonInstallSnippet.poetry for example

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point, changed it 👍

Copy link
Contributor

@antonpirker antonpirker left a comment

Choose a reason for hiding this comment

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

From my limited frontend knowledge this looks good to me.

Comment on lines +48 to +50
const result = getPythonInstallSnippet({
packageName: 'sentry-sdk',
});
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
const result = getPythonInstallSnippet({
packageName: 'sentry-sdk',
});
const result = getPythonInstallSnippet();

Isn't "sentry-sdk" the default packageName?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not in the InstallSnippet; only in the InstallConfig, which is why it needs to be passed in here in the test

Comment on lines +30 to +36
it('generates uv install command with default parameters', () => {
const result = getPythonInstallSnippet({
packageName: 'sentry-sdk',
});

expect(result.uv).toBe(`uv add "sentry-sdk"`);
});
Copy link
Member

Choose a reason for hiding this comment

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

we could combine the tests for uv, pip, and poetry into a single one - this test , for example, could be combined with the first one

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point - changed

Comment on lines +1 to +9
// Mock the modules that cause circular dependencies
jest.mock('sentry/utils/gettingStartedDocs/python', () => {
const original = jest.requireActual('sentry/utils/gettingStartedDocs/python');
return {
...original,
// Mock any functions causing circular dependencies
getPythonProfilingOnboarding: jest.fn(),
};
});
Copy link
Member

Choose a reason for hiding this comment

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

is this needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

We do need it, because otherwise the tests don't work

@priscilawebdev
Copy link
Member

what about falcon?

configurations: getPythonInstallConfig({packageName: "'sentry-sdk[falcon]'"}),

Copy link
Member

@priscilawebdev priscilawebdev left a comment

Choose a reason for hiding this comment

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

left a few suggestions, but overall it looks good to me! 🙌

expect(result.poetry).toBe(`poetry add "sentry-sdk"`);
});

it('generates pip install command with minimum version and extras', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
it('generates pip install command with minimum version and extras', () => {
it('generates install commands with minimum version and extras', () => {

now we test more than just pip :)

const result = getPythonInstallSnippet({
packageName: 'sentry-sdk',
});

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change

@shellmayr shellmayr merged commit 47fec42 into master May 7, 2025
41 checks passed
@shellmayr shellmayr deleted the shellmayr/feat/add-poetry-to-python-install-snippets branch May 7, 2025 09:33
@sentry
Copy link
Contributor

sentry bot commented May 7, 2025

Suspect Issues

This pull request was deployed and Sentry observed the following issues:

  • ‼️ TypeError: (0 , _python.getPythonInstallSnippet) is not a function Object.?(python.spec.tsx) View Issue
  • ‼️ TypeError: (0 , _python.getPythonInstallSnippet) is not a function Object.?(python.spec.tsx) View Issue

Did you find this useful? React with a 👍 or 👎


import {getPythonInstallSnippet} from 'sentry/utils/gettingStartedDocs/python';

describe('getPythonInstallSnippet', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we maybe write those tests against getPythonInstallConfig instead of getPythonInstallSnippet?

getPythonInstallSnippet is only used inside getPythonInstallConfig, so it’s an implementation detail of getPythonInstallSnippet. The “public interface” that is used by consumers is getPythonInstallConfig, and we should be free to change how that is implemented internally without having to change tests

Copy link
Member Author

Choose a reason for hiding this comment

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

Will be resolved in #91119

@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants