-
Notifications
You must be signed in to change notification settings - Fork 769
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
Semantic coloring is not correct for imports and variables #6379
Comments
@IamRezaMousavi, can you include the contents of an output log as described here: I can't reproduce this problem myself. Recording.2024-09-11.091309.mp4 |
this is the log:
|
log with
|
Do you have any other extensions enabled? That log output looks like we're returning semantic data. We don't actually log individual tokens though. My example isn't as complete as yours. Can you share the entire code that you're using? |
No, For python I just installed python extension This is the code: (I can't share more code, sorry :)) import ipaddress
import pprint
import socket
from datetime import datetime
from consts import get_config
from logger import get_logger
from storage import Storage
logger = get_logger()
config = get_config()
class UDPSocketHandler:
def __init__(self) -> None:
self.storage = Storage()
self.can_running = True
def udp_listener(self, filters: dict[str, str] = {}) -> None: # noqa: B006, C901, PLR0912, PLR0915
udp_ip = ''
udp_port = config.getint('LOGPARSER', 'Port')
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
udp_socket.bind((udp_ip, udp_port))
udp_socket.setblocking(False) # noqa: FBT003
logger.info('UDP Socket is binded on port %d', udp_port)
while self.can_running:
try:
data, addr = udp_socket.recvfrom(1024)
logger.info(addr)
# process data
log_str = data.hex()
data_dict = {}
flags_len = 2
flags = log_str[request_id_len:flags_len]
b_flags = format(int(flags, 16), '08b')
ip_version = 'V4'
if int(b_flags[0]):
ip_version = 'V6'
timestamp_len = flags_len + 16
timestamp = log_str[flags_len:timestamp_len]
d_timestamp = int(timestamp, 16)
data_dict.update({'timestamp': datetime.fromtimestamp(d_timestamp)})
source_port_len = timestamp_len + 4
source_port = log_str[receive_byte_length_len:source_port_len]
d_source_port = int(source_port, 16)
data_dict.update({'src_port': d_source_port})
logger.info('src_port = %s', data_dict['src_port'])
if filters.get('src_port') and filters['src_port'] != data_dict['src_port']:
continue
dst_port_len = source_port_len + 4
dst_port = log_str[source_port_len:dst_port_len]
d_dst_port = int(dst_port, 16)
data_dict.update({'dst_port': d_dst_port})
if ip_version == 'V4':
src_ip_len = dst_port_len + 8
dst_ip_len = src_ip_len + 8
elif ip_version == 'V6':
src_ip_len = dst_port_len + 32
dst_ip_len = src_ip_len + 32
data_dict.update({'ip_version': ip_version})
src_ip = log_str[dst_port_len:src_ip_len]
d_src_ip = int(src_ip, 16)
src_ip_address = str(ipaddress.ip_address(d_src_ip))
data_dict.update({'src_ip': src_ip_address})
dst_ip = log_str[src_ip_len:dst_ip_len]
d_dst_ip = int(dst_ip, 16)
dst_ip_address = str(ipaddress.ip_address(d_dst_ip))
data_dict.update({'dst_ip': dst_ip_address})
logger.info(pprint.pformat(data_dict))
self.storage.update_data(data, data_dict)
except BlockingIOError:
continue
except Exception:
logger.exception('')
continue
if __name__ == '__main__':
s = UDPSocketHandler()
s.udp_listener() |
In those screenshots it looks correct. It doesn't have the errors you showed previously? Only the unused variables are a different contrast. |
It's incorrect. Used variables have different contrast also. eq: |
That means we think those variables aren't used. It's not the semantic coloring, it's a diagnostic hint that is coming back. If you hover over it should show something like this: If you close and reopen VS code (or run |
No |
Originally posted by @IamRezaMousavi in #6358
The text was updated successfully, but these errors were encountered: