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

error pylance with parameter in serializer #6985

Open
freyesval opened this issue Feb 25, 2025 · 1 comment
Open

error pylance with parameter in serializer #6985

freyesval opened this issue Feb 25, 2025 · 1 comment
Assignees
Labels
needs repro Issue has not been reproduced yet waiting for user response Requires more information from user

Comments

@freyesval
Copy link

freyesval commented Feb 25, 2025

Type: Bug

i had this basic factory of serializer in python:

def create_serializer_with_create_and_user(model_name):
    model = apps.get_model('admin_service', model_name)
    Meta = type('Meta', (), {'model': model, 'fields': '__all__'})

    def create(self, validated_data):
        current_user = validated_data.pop('current_user', None)
        instance = model.objects.create(**validated_data)
        if current_user is not None:
            instance.save(current_user=current_user)
        return instance

    return type(f'{model_name}Serializer', (ExcludeSoftDeleteFieldsSerializer,), {'Meta': Meta, 'create': create})

Pylance shows an error:
No parameter named "current_user" Pylance reportCallIssue
but in my model, i obtain this parameter like kwarg:
current_user = kwargs.pop('current_user', None)
so, could you fix this pylance error?
thanks

Extension version: 2025.2.1
VS Code version: Code 1.97.2 (e54c774e0add60467559eb0d1e229c6452cf8447, 2025-02-12T23:20:35.343Z)
OS version: Windows_NT x64 10.0.22635
Modes:

System Added Logs
2025-02-25 10:09:20.458 [info] (Client) Pylance async client (2025.2.1) started with python extension (2025.0.0)
2025-02-25 10:09:21.678 [info] [Info  - 10:09:21 AM] (28664) Server root directory: file:///c%3A/Users/56976/.vscode/extensions/ms-python.vscode-pylance-2025.2.1/dist
2025-02-25 10:09:21.679 [info] [Info  - 10:09:21 AM] (28664) Pylance language server 2025.2.1 (pyright version 1.1.393, commit 3763156f) starting
2025-02-25 10:09:21.680 [info] [Info  - 10:09:21 AM] (28664) Starting service instance "backend-quimun-python"
2025-02-25 10:09:21.752 [info] [Info  - 10:09:21 AM] (28664) Setting environmentName for service "backend-quimun-python": "3.9.13 (.env venv)"
2025-02-25 10:09:21.752 [info] [Info  - 10:09:21 AM] (28664) Setting pythonPath for service "backend-quimun-python": "c:\Users\56976\Documents\GitHub\backend-quimun-python\.env\Scripts\python.exe"
2025-02-25 10:09:21.753 [info] [Info  - 10:09:21 AM] (28664) No include entries specified; assuming c:\Users\56976\Documents\GitHub\backend-quimun-python
2025-02-25 10:09:21.754 [info] [Info  - 10:09:21 AM] (28664) Auto-excluding **/node_modules
2025-02-25 10:09:21.754 [info] [Info  - 10:09:21 AM] (28664) Auto-excluding **/__pycache__
2025-02-25 10:09:21.754 [info] [Info  - 10:09:21 AM] (28664) Auto-excluding **/.*
2025-02-25 10:09:21.912 [info] [Info  - 10:09:21 AM] (28664) Assuming Python version 3.9.13.final.0
2025-02-25 10:09:22.460 [info] [Info  - 10:09:22 AM] (28664) Found 223 source files
2025-02-25 10:09:22.595 [info] [Info  - 10:09:22 AM] (28664) virtual workspace: vscode-chat-code-block://aeeefb4a-e0ff-4a35-b6e5-bbb5e56caaf6/
2025-02-25 10:09:22.599 [info] [Info  - 10:09:22 AM] (28664) Starting service instance "<default>"
2025-02-25 10:09:22.654 [info] [Info  - 10:09:22 AM] (28664) Background analysis(1) root directory: file:///c%3A/Users/56976/.vscode/extensions/ms-python.vscode-pylance-2025.2.1/dist
2025-02-25 10:09:22.663 [info] [Info  - 10:09:22 AM] (28664) Background analysis(1) started
2025-02-25 10:09:22.693 [info] [Info  - 10:09:22 AM] (28664) Setting environmentName for service "<default>": "3.9.13 (.env venv)"
2025-02-25 10:09:22.693 [info] [Info  - 10:09:22 AM] (28664) No include entries specified; assuming vscode-chat-code-block://aeeefb4a-e0ff-4a35-b6e5-bbb5e56caaf6/
2025-02-25 10:09:22.694 [info] [Info  - 10:09:22 AM] (28664) Auto-excluding **/node_modules
2025-02-25 10:09:22.694 [info] [Info  - 10:09:22 AM] (28664) Auto-excluding **/__pycache__
2025-02-25 10:09:22.694 [info] [Info  - 10:09:22 AM] (28664) Auto-excluding **/.*
2025-02-25 10:09:23.206 [info] [Info  - 10:09:23 AM] (28664) Assuming Python version 3.9.20.final.0
2025-02-25 10:09:23.461 [info] [Error - 10:09:23 AM] (28664) File or directory "vscode-chat-code-block://aeeefb4a-e0ff-4a35-b6e5-bbb5e56caaf6/" does not exist.
2025-02-25 10:09:23.461 [info] [Info  - 10:09:23 AM] (28664) No source files found.
2025-02-25 10:09:23.495 [info] [Info  - 10:09:23 AM] (28664) Starting service instance "<default>"
2025-02-25 10:09:24.959 [info] [Info  - 10:09:24 AM] (28664) Indexer background runner(2) root directory: file:///c%3A/Users/56976/.vscode/extensions/ms-python.vscode-pylance-2025.2.1/dist (index)
2025-02-25 10:09:24.959 [info] [Info  - 10:09:24 AM] (28664) Indexing(2) started
2025-02-25 10:09:24.963 [info] [Info  - 10:09:24 AM] (28664) scanned(2) 95 files over 1 exec env
2025-02-25 10:09:24.980 [info] [Info  - 10:09:24 AM] (28664) Setting environmentName for service "<default>": "3.9.13 (.env venv)"
2025-02-25 10:09:24.980 [info] [Info  - 10:09:24 AM] (28664) Setting pythonPath for service "<default>": "c:\Users\56976\Documents\GitHub\backend-quimun-python\.env\Scripts\python.exe"
2025-02-25 10:09:24.981 [info] [Info  - 10:09:24 AM] (28664) No include entries specified; assuming \<default workspace root>
2025-02-25 10:09:24.981 [info] [Info  - 10:09:24 AM] (28664) Auto-excluding **/node_modules
2025-02-25 10:09:24.981 [info] [Info  - 10:09:24 AM] (28664) Auto-excluding **/__pycache__
2025-02-25 10:09:24.981 [info] [Info  - 10:09:24 AM] (28664) Auto-excluding **/.*
2025-02-25 10:09:25.087 [info] [Info  - 10:09:25 AM] (28664) Assuming Python version 3.9.13.final.0
2025-02-25 10:09:25.247 [info] [Error - 10:09:25 AM] (28664) File or directory "\<default workspace root>" does not exist.
2025-02-25 10:09:25.247 [info] [Info  - 10:09:25 AM] (28664) No source files found.
2025-02-25 10:09:25.470 [info] [Info  - 10:09:25 AM] (28664) indexed(2) 95 files over 1 exec env
2025-02-25 10:09:25.511 [info] [Info  - 10:09:25 AM] (28664) Indexing finished(2).
2025-02-25 10:09:25.637 [info] [Info  - 10:09:25 AM] (28664) Background analysis(3) root directory: file:///c%3A/Users/56976/.vscode/extensions/ms-python.vscode-pylance-2025.2.1/dist
2025-02-25 10:09:25.639 [info] [Info  - 10:09:25 AM] (28664) Background analysis(3) started
2025-02-25 12:21:28.095 [info] [Info  - 12:21:28 PM] (28664) Setting environmentName for service "backend-quimun-python": "3.9.13 (.env venv)"
2025-02-25 12:21:28.096 [info] [Info  - 12:21:28 PM] (28664) Setting pythonPath for service "backend-quimun-python": "c:\Users\56976\Documents\GitHub\backend-quimun-python\.env\Scripts\python.exe"
2025-02-25 12:21:28.096 [info] [Info  - 12:21:28 PM] (28664) No include entries specified; assuming c:\Users\56976\Documents\GitHub\backend-quimun-python
2025-02-25 12:21:28.096 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/node_modules
2025-02-25 12:21:28.096 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/__pycache__
2025-02-25 12:21:28.096 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/.*
2025-02-25 12:21:28.185 [info] [Info  - 12:21:28 PM] (28664) Assuming Python version 3.9.13.final.0
2025-02-25 12:21:28.362 [info] [Info  - 12:21:28 PM] (28664) Found 223 source files
2025-02-25 12:21:28.418 [info] [Info  - 12:21:28 PM] (28664) Setting environmentName for service "<default>": "3.9.13 (.env venv)"
2025-02-25 12:21:28.418 [info] [Info  - 12:21:28 PM] (28664) No include entries specified; assuming vscode-chat-code-block://aeeefb4a-e0ff-4a35-b6e5-bbb5e56caaf6/
2025-02-25 12:21:28.418 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/node_modules
2025-02-25 12:21:28.418 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/__pycache__
2025-02-25 12:21:28.418 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/.*
2025-02-25 12:21:28.626 [info] [Info  - 12:21:28 PM] (28664) Assuming Python version 3.9.20.final.0
2025-02-25 12:21:28.862 [info] [Error - 12:21:28 PM] (28664) File or directory "vscode-chat-code-block://aeeefb4a-e0ff-4a35-b6e5-bbb5e56caaf6/" does not exist.
2025-02-25 12:21:28.862 [info] [Info  - 12:21:28 PM] (28664) No source files found.
2025-02-25 12:21:28.910 [info] [Info  - 12:21:28 PM] (28664) Setting environmentName for service "<default>": "3.9.13 (.env venv)"
2025-02-25 12:21:28.910 [info] [Info  - 12:21:28 PM] (28664) Setting pythonPath for service "<default>": "c:\Users\56976\Documents\GitHub\backend-quimun-python\.env\Scripts\python.exe"
2025-02-25 12:21:28.910 [info] [Info  - 12:21:28 PM] (28664) No include entries specified; assuming \<default workspace root>
2025-02-25 12:21:28.911 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/node_modules
2025-02-25 12:21:28.911 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/__pycache__
2025-02-25 12:21:28.911 [info] [Info  - 12:21:28 PM] (28664) Auto-excluding **/.*
2025-02-25 12:21:29.018 [info] [Info  - 12:21:29 PM] (28664) Assuming Python version 3.9.13.final.0
2025-02-25 12:21:29.178 [info] [Error - 12:21:29 PM] (28664) File or directory "\<default workspace root>" does not exist.
2025-02-25 12:21:29.178 [info] [Info  - 12:21:29 PM] (28664) No source files found.
2025-02-25 12:21:29.217 [info] [Info  - 12:21:29 PM] (28664) Indexer background runner(4) root directory: file:///c%3A/Users/56976/.vscode/extensions/ms-python.vscode-pylance-2025.2.1/dist (index)
2025-02-25 12:21:29.217 [info] [Info  - 12:21:29 PM] (28664) Indexing(4) started
2025-02-25 12:21:29.313 [info] [Info  - 12:21:29 PM] (28664) scanned(4) 95 files over 1 exec env
2025-02-25 12:21:29.593 [info] [Info  - 12:21:29 PM] (28664) indexed(4) 95 files over 1 exec env
2025-02-25 12:21:29.631 [info] [Info  - 12:21:29 PM] (28664) Indexing finished(4).

System Info
Item Value
CPUs AMD Ryzen 9 5980HS with Radeon Graphics (16 x 3294)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off
Load (avg) undefined
Memory (System) 15.41GB (5.90GB free)
Process Argv --crash-reporter-id c4dcfb0d-4850-47a9-9209-23ad79693399
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vscod805cf:30301675
binariesv615:30325510
py29gd2263:31024239
c4g48928:30535728
azure-dev_surveyone:30548225
a9j8j154:30646983
962ge761:30959799
2e7ec940:31000449
pythontbext0:30879054
cppperfnew:31000557
dwnewjupyter:31046869
nativerepl2:31139839
pythonrstrctxt:31112756
nativeloc2:31192216
iacca1:31171482
5fd0e150:31155592
dwcopilot:31170013
stablechunks:31184530
6074i472:31201624
dwoutputs:31242946
hdaa2157:31222309
copilot_t_ci:31222730
jda6j935:31233686
copilothoveroff:31245427

@github-actions github-actions bot added the needs repro Issue has not been reproduced yet label Feb 25, 2025
@debonte
Copy link
Contributor

debonte commented Feb 28, 2025

We can't reproduce the problem you're seeing since the code sample above is incomplete. It's missing the declaration of apps and the related imports. A list of required packages and versions would be helpful as well.

That said, from your description, it sounds like whatever package you are using (django?) has some dynamic behavior that static analysis tools may not be capable of understanding.

@debonte debonte added the waiting for user response Requires more information from user label Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue has not been reproduced yet waiting for user response Requires more information from user
Projects
None yet
Development

No branches or pull requests

3 participants