I develop a basic Pydantic Settings class as follows, based on the Pydantic document:
from pydantic_settings import BaseSettings
from pydantic import (
AliasChoices,
AmqpDsn,
Field,
PostgresDsn,
RedisDsn,
)
class Settings(BaseSettings):
redis_dsn: RedisDsn = Field(
'redis://user:pass@localhost:6379/1',
validation_alias=AliasChoices('service_redis_dsn', 'redis_url')
)
amqp_dsn: AmqpDsn = 'amqp://user:pass@localhost:5672/'
pg_dsn: PostgresDsn = 'postgres://user:pass@localhost:5432/foobar'
settings = Settings()
The sample above ran without any errors. Now, when I use that instance in any way (i.e. by printing it as print(setting)
), three defined ports in the model are added to the already-existing forwarded ports in VS Code:
I also receive the notification shown below:
In various runs, the port number contained in the message above can be modified.
I discovered that Visual Studio Code has a built-in remote.autoForwardPortsSource
setting that is enabled by default. Disabling it resolves the issue, though, the setting description states:
When enabled, new running processes are detected and ports that they
listen on are automatically forwarded.
There is nothing about using an instance of a class but running the process. So, can someone please explain why this is happening? Is this the kind of behavior expected? And other than disabling the VS Code setting, how can I stop those ports from automatically forwarding?